Compiling and exporting classes 281
2. 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.
3. Create a new layer, drag it above the content layer, and rename it actions.
4. Add the following ActionScript code to Frame 1 of the actions layer on the main Timeline:
my_pb.indeterminate = true;
5.
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);
}
6.
Create a new keyframe on Frame 10 of the actions layer and add the following
ActionScript:
stop();
7.
Create a new keyframe on Frame 10 of the content layer and drag several components onto
the Stage.
8. 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.
9. 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.
10. Select File > Publish Settings.
11. In the Publish Settings dialog box, select the Flash tab.
12. Click the Settings button next to the ActionScript version pop-up menu to open the
ActionScript Settings dialog box.
13. 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.
14. Click OK to close the ActionScript Settings dialog box, and then click OK to close the
Publish Settings dialog box.