By default, classes used by a SWF file are packaged and exported in the SWF file's first frame. You can also specify a different 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 (such as components). 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:
Select File > New and then select Flash Document. Save the new document as exportClasses.fla.
Rename the default layer to content, drag a ProgressBar component from the Components panel to the Stage, and give it an instance name of my_pb.
Create a new layer, drag it above the content layer, and rename it actions.
Add the following ActionScript code to Frame 1 of the actions layer on the main Timeline:
my_pb.indeterminate = true;
Create a new keyframe on Frame 2 of the actions layer and add the following ActionScript code:
var classesFrame:Number = 10;
if (_framesloaded < classesFrame) {
trace(this.getBytesLoaded() + " of " + this.getBytesTotal() + " bytes loaded");
gotoAndPlay(1);
} else {
gotoAndStop(classesFrame);
}
Create a new keyframe on Frame 10 of the actions layer and add the following ActionScript:
stop();
Create a new keyframe on Frame 10 of the content layer and drag several components onto the Stage.
Right-click each component (except the ProgressBar) in the Library panel and select Linkage from the context menu to launch the Linkage Properties dialog box.
In the Linkage Properties dialog box, make sure that Export for ActionScript is selected, deselect the Export in First Frame check box, and click OK.
Select File > Publish Settings.
In the Publish Settings dialog box, select the Flash tab.
Click the Settings button next to the ActionScript version pop-up menu to open the ActionScript Settings dialog box.
In the Export Frame for Classes text box, enter the number of the frame where you want to export your class code (Frame 10).
If the frame specified does not exist in the timeline, you 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 Settings dialog box.
Select Control > Test Movie to test the Flash document. If the Components load too quickly, select View > Simulate Download from the SWF file. Flash simulates downloading the Flash document at a lower speed, which allows you to see the progress bar component animate as the class files download.
This page should say 'Next learn what an ASO is", instead of "For more information on ASO files, see Using ASO files." The current wording misleads one to think that ASO's have already been touched on on this page, which they haven't.
Comments
oakiedave said on Mar 22, 2008 at 9:14 PM :