Preloading in AS3
Honestly, I never really had a problem with preloading in AS3 previously. Mainly because of my friends over at Urban Squall with their post on the last preloader you’ll ever need, which can be found here. Then a friend of mine wanted to preload his swf while coding in an FLA or in a document class, which I didn’t know the answer to. Because I usually code with the Flex SDK, thus you can’t use Urban Squall’s [Frame] tag solution.
The solutions that people are throwing around is simply using “loaderInfo.addEventListener(Event.COMPLETE, myFunctionHere)” and putting that in their document class or first frame of their timeline. This doesn’t work. That is unless you are putting everything after the first frame of your movie. But for peeps that are creating robust apps and games, they are exporting assets in their library. These will NOT be preloaded with code on the first frame.
So let’s recap the various solutions and see if they work:
Everything exporting or on the first frame with preload code — It will NOT preload everything
JUST preload code on the first frame and everything on the second frame or beyond — This DOES work
Have a shell SWF that is completely light weight (like 5-10k) that just loads in the content swf — This solution would work as well
I honestly don’t like any of these. I am glad that I 99.9% of the time work with the Flex SDK and can use slightly more eligant solutions like using the [Frame] tag and sticking a class to monitor everything before the shit hits the fan in the document class.