If you use behaviors placed on screens (or other instances), remember to document the location
on Frame 1 of the main Timeline. This is particularly important if you also place ActionScript on
the Timeline. The following code is an example of the comment you might want to add to your
FLA file:
/*
On Frame 1 of main Timeline.
ActionScript is placed on individual screens and directly on instances in
addition to the code on the Timeline (frame 1 of root screen).
...
*/
Placing code in the FLA file
Using behaviors on screens while placing ActionScript on the main Timeline makes a
screen-based FLA file less complex and easier to work with than a regular FLA document.
Behavior code is sometimes added to instances where it might take a long time to create because
of its complexity. The convenience of using behaviors might vastly outweigh any drawbacks if the
behaviors you add to a screens document are quite complex to write yourself.
New Flash users frequently like the visual approach of placing ActionScript for a particular screen
directly on an object. When you click the screen or a movie clip, you see the code that
corresponds to the instance or the name of the function that's called for that instance. This makes
navigating an application and associated ActionScript visual. It's also easier to understand the
hierarchy of the application while in the authoring environment.
If you decide to attach ActionScript to symbol instances on the Stage and directly on screens, try
to place all your ActionScript only in these two places to reduce complexity.
If you place ActionScript on screens and either on the Timeline or in external files, try to place all
your ActionScript in only these two of places to reduce complexity.
Using external ActionScript
You can organize your screen-based FLA file by writing external code and not having any code in
the document. When you use external ActionScript, try to keep most of it in external AS files to
avoid complexity. Placing ActionScript directly on screens is acceptable, but avoid placing
ActionScript on instances on the Stage.
You can create a class that extends the Form class. For example, you could write a class called
. In the Property inspector, you would change the class name from
MyForm
. The
MyForm
MyForm
class MyForm extends mx.screens.Form {
function MyForm() {
trace("constructor: "+this);
}
}
class would look similar to the following code:
mx.screens.Form
Screens conventions
to
109
Need help?
Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?
Questions and answers