The following example shows that you can then reference either of the classes directly in the same
script:
var myRos:Rosencrantz = new Rosencrantz();
var myGuil:Guildenstern = new Guildenstern();
The
statement applies only to the current script (frame or object) in which it's called. If
import
an imported class is not used in a script, the class is not included in the resulting SWF file's
bytecode, and the class isn't available to any SWF files that the FLA file containing the
statement might load. For more information, see
Compiling and exporting classes
By default, classes used by a SWF file are packaged and exported in the SWF file's first frame. You
can also specify the frame where your classes are packaged and exported. This is useful, for
example, if a SWF file uses many classes that require a long time to download. If the classes are
exported in the first frame, the user has to wait until all the class code has downloaded before that
frame appears. By specifying a later frame in the Timeline, you could display a short loading
animation in the first few frames of the Timeline while the class code in the later frame
downloads.
To specify the export frame for classes for a Flash document:
With a FLA file open, select File > Publish Settings.
1.
In the Publish Settings dialog box, click the Flash tab.
2.
Click the Settings button next to the ActionScript version pop-up menu to open the
3.
ActionScript Settings dialog box.
In the Export Frame for Classes text box, enter the number of the frame where you want to
4.
export your class code.
If the frame specified does not exist in the Timeline, you will get an error message when you
publish your SWF file.
Click OK to close the ActionScript Settings dialog box, and then click OK to close the Publish
5.
Settings dialog box.
During compilation, Flash sometimes creates files with .aso extensions in the /aso subdirectory of
the default global classpath directory (see
The .aso extension stands for ActionScript object (ASO). These files contain the compiled form of
a class file.
The compiler creates ASO files for caching purposes. You might notice that your first compilation
is slower than subsequent compilations. This is because only the AS files that have changed are
recompiled into ASO files. For unchanged AS files, the compiler reads the already-compiled
bytecode directly out of the ASO file instead of recompiling the AS file.
The ASO file format is an intermediate format developed for internal use only. It is not a
documented file format and is not intended to be redistributed.
272
Chapter 10: Creating Custom Classes with ActionScript 2.0
in Flash ActionScript Language Reference.
import
"Global and document-level classpaths" on page
import
268).
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