January 22, 2007
AS3-only Preload solved by Bit-101
After my spending time recently trying to build an AS3-only preloader, wading through many under-documented features of AS3, Jesse shoots me an email letting me know that Keith Peters has posted the answer. Bit-101 now has a tutorial on how to build a preloader for AS3-only projects (no MXML) that compile using MXMLC.
Yes! Thanks, Keith! Thanks, Jesse!
I did learn a few things during my research, though. Maybe you've seen these...maybe you haven't:
- if you are about to directly call the constructor of a new custom class (ex: var m:MyClass = new MyClass() ), the current class will become dependent on the new class. The first class will be required to suck in all of the assets declared within that new class via the [embed] tag before construction. You can get around this dependency by using "getDefinitionByName('MyClass')" as seen in Keith's tutorial.
- you can add additional frames to a swf at compile-time by using the "-frame [myLabel] [myClassName]" param of MXMLC. As many as you want. You might also have to use the "-includes [myClassName]" param to include the class in the build if it's not directly referenced elsewhere.
- you can add additional script to any frame of a movieclip on your main timeline using "myMovieClip.addFrameScript(frameNum, callbackFunction)", where frameNum starts counting from zero.
- adding the "-keep-generated-actionscript" parameter to your compile is a very handy way to see what classes are auto-generated by MXMLC behind the scenes. It shows you classes for all of your embedded assets, so if one seems missing from your swf, it's easy to check that "generated" folder to see if that asset got left out of the compile.
- Flex now seems to log trace output to c:\Documents and Settings\[userName]\Application Data\Macromedia\flashlog.txt instead of the path specified in your mm.cfg file.
- you can use the "-link-report [reportName.xml]" to generate an xml file that tells you all of the dependencies of each compiled class in your swf. If you want to know why all of your assets dogpile onto frame 1 and nuke your preloader, check this file to make sure your preload class has no direct reference to your main class.
Posted by andy at 11:45 AM
|
Comments (0)