“Preloader junkyard” or how to keep everything in one clip extension.

July 5th, 2007 by Slav

You might have experienced the following situation : Just created a flash game or app which is too big to go online without preloader. You have 2 options.

  1. Create 1 file so preloader must be inside the same file as app.
  2. Create a separate small preloader swf that will load your big file.

Although the second solution is more elegant, there are various reasons why you will use option number 1.

When doing the preloader in the same file, you have to specify for classes to be exported on a later frame such as 5, and place all preloader functionality in frames before that. You also have to go trough all of your movie clips in the library that are being attached later during the runtime and uncheck “Export on the first frame” option in the Linkage properties box. This creates a problem : Unless the movie clips are not physically used somewhere on the stage , flash will not compile this movie clips to the final swf file. 

My approach to solving this problem is to collect all the MCs I am going to be using later via attachMovie on the stage and place them on the same frame I specified for the classes to be exported. I like to do this on the frame 5, but you may choose whatever frame you wish, as long as the classes are being imported on that frame too. This is of course quite tedious job as you have to go through all the library and firstly right click on the Library item , choose linkage, uncheck “Export in first frame”, click OK, drag the MC onto the stage on the frame 5. And you have to repeat it for every item that has to be exported for actionScript. Chances are you may miss one or two, if your app is quite large, or library too messy…

Enter the [Slav]DumpExportMCs :

  1. Finish building your app or game.
  2. Specify “Export frame for classes” as 5 (File > Publish Setting > Flash > ActionScript 2.0 Settings) 
  3. Run : Commands > [Slav]DumpExportMCs
  4. Put preloader on the frame 1 and your app on whichever frame you want as long as it’s after 5.

Extension will crawl through your library and if there is a movie clip with export for AS settings it will uncheck it’s export on the first frame and dump it on the frame 5 of the _root timeline.


Posted in flash, JSFL

(comments are closed).