Using ActionScript 2.0 Components |
|
|
|
| Working with Components > Using a preloader with components | |||
Preloading involves loading some of the data for a SWF file before the user starts interacting with it. By default, components and classes are set to export in the first frame of the document that contains components. Because the components and classes are the first data to load, you might have problems implementing a progress bar or loading animation. Specifically, the components and classes might load before the progress bar, but you want the progress bar to reflect the loading progress of all data (including classes). Therefore, you should load the classes after other parts of the SWF file, but before you use components.
To do this, when you create a custom preloader for an application containing components, set the file's publish settings to export all the classes to the frame containing your components. To see a list of all the components in the Halo and Sample themes that have their assets set to Export in First Frame, see Changing export settings.
To change the export frame for all your classes:You cannot use any classes until the playhead reaches the frame you choose to load them into. Because components require classes for their functionality, you must load components after the frame specified for loading classes. If you export your classes to 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 components, you must also 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.
|
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. |
To change the frame into which components are exported: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 Step 7.
|
NOTE |
Components must be exported after the ActionScript classes that they use. |
|
|
|
|