Flash CS3 Documentation |
|||
| Learning ActionScript 2.0 in Adobe Flash > Classes > About working with built-in classes > Preloading class files | |||
This section describes some of the methodologies for preloading and exporting classes in Flash (including the classes that components in version 2 of the Component Architecture use). Preloading involves loading some of the data for a SWF file before the user starts interacting with it. Flash imports classes on the first frame of a SWF file when you use external classes, and this data is the first element to load into a SWF file. It is similar for the component classes, because the framework for components also loads into the first frame of a SWF file. When you build large applications, the loading time can be lengthy when you must import data, so you must deal with this data intelligently, as the following procedures show.
Because the classes are the first data to load, you might have problems creating a progress bar or loading animation if the classes load before the progress bar, because you probably want the progress bar to reflect the loading progress of all data (including classes). Therefore, you want to load the classes after other parts of the SWF file, but before you use components.
The following procedure shows you how to change the frame in which classes load into a SWF file.
You cannot use any classes until the playhead reaches the frame you choose to load them into. For example, version 2 components require classes for their functionality, so you must load components after the Export frame for ActionScript 2.0 classes. If you export for Frame 3, you cannot use anything from those classes until the playhead reaches Frame 3 and loads the data.
If you want to preload a file that uses classes, such as version 2 component classes, you must preload the components in the SWF file. To accomplish this, you must set your components to export for a different frame in the SWF file. By default, the UI components export in Frame 1 of the SWF file, so make sure that you deselect Export in First Frame from the component's Linkage dialog box.
|
NOTE |
|
If you add a component to the Stage using ActionScript, then you need to drag an instance of the component you want to add onto the pasteboard (the area around the Stage). This tells Flash that you're using the component in your application, and that its not an unused library item. Remember, Flash does not add unused library items to SWF files. |
If components do not load on the first frame, you can create a custom progress bar for the first frame of the SWF file. Do not reference any components in your ActionScript or include any components on the Stage until you load the classes for the frame you specified in the Export Frame for Classes text box.
|
CAUTION |
|
You must export components after the ActionScript classes that they use. |
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000818.html