By default, when the Flash authoring tool compiles a .swf file, it exports all classes in the .swf file's first frame. As a result, all classes used in the .swf file must finish loading before the .swf file's first frame is displayed. Depending on the total size of the classes included in the .swf file, this loading process can result in a noticeable delay before the .swf file begins to play.
To avoid the class-loading delay, we can export a .swf file's classes after Frame 1 in the main timeline, and then provide a simple timeline script that displays progress information during the class-loading process.
As an example, let's change our sky.fla file so that the classes it uses
aren't loaded until Frame 15. Note, however, that a .swf file's document class—and every class
the document class references, whether directly or indirectly—always
loads in Frame 1. Hence, to prevent the Star class from loading before Frame 1, we
must first remove the instance names from all manually created
Star instances and we will delete
the definitions for the variables
star5 from the Sky class code. To remove instance names,
we select each Star instance on
Stage and delete its name from the Properties panel.
The following procedures describe how to load sky.fla's classes at Frame 15 and display a loading message while the classes load.
First, follow these steps to instruct Flash to export sky.fla's classes at Frame 15:
Open sky.fla in the Flash authoring tool.
Choose File → ...