There are many very good tutorials on creating an Actionscript preloader for previous versions of Adobe Flash (see the Avoider Game, or the newer tutorial on Activetuts+). The principle of a preloader is to allow the Flash program to start displaying something on screen right away, along with some sort of loading screen with time left to finish loading. This works great especially for large Flash projects.
The problem with these tutorials is that none of them address CS5. While the Activetuts+ tutorial does describe CS4 well, there is quite a bit of CS3 mention, which makes things a little confusing. Fortunately, CS5 preloaders are relatively simple.
The below essentially assumes your Flash program is a single frame, utilizing Actionscript to generate your animation/movie. Following the guidelines given in the above tutorials:
- We will use the same “3 frame model”, so create keyframes in frames 2 and 3 as described.
- Go to File > Publish Settings and set the Export Frame to 2.
- Create the preloader on Frame 1. This can be Actionscript based as well, not necessarily an instance on the stage as described in the tutorials.
- Add the preloader code to the project’s main document class. We used more of the Avoider model, so we didn’t have to create another preloader class. Seems simpler this way than the Activetuts+ model.
- Add the necessary stop() call in the “Actions” of Frame 1.
- Thats it!
Note that we were able to import sound to the library without trouble, exporting it to the new default frame 2.
The big change from the prior tutorials is that the AssetHolder in frame 2 is not needed.
This technique also seems to work fine with Text Layout Framework (TLF) text. Just make sure the default linkage is set to “Merged into code” under Advanced Actionscript Settings.
On a less positive note, the preloader doesn’t seem to work with Android, as the program seems to skip right over. We aren’t hopeful for iOS either, but we haven’t tried it yet.