New settings in “Publish Settings…”

There are some tricky settings come with FlashCS3, which may cause a lot of frustration, if not used properly. As Flash now supports a document level “Class”, one can assign a “Class” to whole of the “Fla”. This class is the point of entry to the application one might be developing. Lets try a simple code here.

doc.JPG
Create an “FLA” and name it “class.fla” ( name is not important, you can name it whatever you want ). Now open the properties pannel for the “FLA” and assign a “Class” named “Mclass” for “Document class”. Create a “.as” file in the same folder as the FLA and name it “Mclass.as”. Lets create a movieclip in our FLA.Drag the Movieclip from Library to Stage so that there would be an instance of the movieclip on stage. Name the instance as “my_mc” on stage.Open “Mclass.as” and put the code below
package {
import flash.display.MovieClip;
public class Mclass extends MovieClip{
public var my_mc:MovieClip;
public function Mclass(){
trace(‘sam : ‘+my_mc.name);
}
}
}

Now if you test your movie, it should run fine with the trace. Is it running fine?!! If yes, you do not know about something which is acting currently in your favour. If the movie is not running fine ( “Compiler Errors” pannel is showing some error messages ), you must search about that something which is not working in favour of you.We, will see that in a minute.Before that lets test our movie with a little modified code and see what is happening.Put the code below instead of the previous code in “Mclass.as”.
package {
import flash.display.MovieClip;
public class Mclass extends MovieClip{
public function Mclass(){
trace(‘sam : ‘+my_mc.name);
}
}
}

If you test movie now, for those who felt the luck was not in favour, will suddenly feel that everything is working fine and luck is with them.But there would be dissapointment for those who felt that their movie was working fine previously.Now they should get an error in “Compiler Errors” pannel.
Well, well, the culprit is the publish settings.Lets have a look at it.Open the publish setting dialogue box by going through “File > Publish Settings…”. Now click the “Settings…” button next to “ActionScript version” drop down list (By the way, your “ActionScript version” setting should be set to “ActionScript3.0”). This should open “ActionScript 3.0 Settings” dialogue box. There is a checkbox just next to “Stage” and before “Automatically declare stage instances“. This is the setting, one must keep an eye on.

setting.JPG
What does it do?
When this checkbox is selected, Flash automatically declares “named instances on Stage”.That means in a Document class, there should not be any declaration for the named instances on stage as
public var my_mc:MovieClip;
When this check box is not selected, one must declare the “named instances on Stage”. One must declare them in the class before using it.
Now, if we remove the instance name from the properties panel, we can safely test our movie without any error, thats because anyway we can not access that movieclip.

So, for those of you who have “Automatically declare stage instances” setting on, the second bunch of code will work and for those who have “Automatically declare stage instances” setting off, the first bunch of code will work. You can see, there is only one line difference between both the codes and that is declaration of the movieclip.

Happy Flashing :)

Advertisements

2 thoughts on “New settings in “Publish Settings…”

  1. This is the first time I comment here and I should say you share genuine, and quality information for other bloggers! Good job.
    p.s. You have an awesome template . Where have you got it from?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s