EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - How Classes Are Compiled and Exported

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
174 Chapter 9: Creating Classes with ActionScript 2.0
In some cases, however, you might want to add and access properties or methods of a class at
runtime that arent defined in the original class definition. The
dynamic class modifier lets you do
just that. For example, the following code adds the
dynamic modifier to the Person class
discussed previously:
dynamic class Person {
var name:String;
var age:Number;
}
Now, instances of the Person class can add and access properties and methods that arent defined
in the original class.
var a_person:Person = new Person();
a_person.hairColor = "blue"; // no compiler error because class is dynamic
Subclasses of dynamic classes are also dynamic.
How classes are compiled and exported
By default, classes used by a SWF file are packaged and exported on the SWF’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 on the first frame, the user would have to wait until all the class code has downloaded
before that frame would appear. 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:
1 With a FLA file open, select File > Publish Settings.
2 In the Publish Settings dialog box, click the Flash tab.
3 Click the Settings button next to the ActionScript version pop-up menu to open the
ActionScript Settings dialog box.
4 In the Export Frame for Classes text box, enter the number of the frame where you want to
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.
5 Click OK to close the ActionScript Settings dialog box, then click OK to close the Publish
Settings dialog box.

Table of Contents

Related product manuals