An Actionscript preloader application

For those that are struggling with how to show the loading status of their flash application or website before the main file initially loads, I have a solution included in this blog. The problem this code addresses is when you need to load a large flash file all at once (i.e. don’t want to load it piecemeal) and want to show the user the status of the load.

Actually this is a derivative of a contributor to the flash forums (OOPete), and the credit is due mostly to him – click here to read the forum. However, I have added a progress component and included the entirety of the code for re-use in this posting.

There is an alternative to using a pre-loader application such as this, which is to set all of the large components in your library to not export on the first frame of the flash application and create a preloader function within the main file. However, there are reasons not to do this, this approach is beyond the scope of this posting, and the code below works fine.

This code will display a flash window that is 800×600 in size and a progress bar component that displays the percentage of the main .swf application that is being loaded as it loads. The window size can be altered in the .fla file. When the main .swf application is loaded, it is transferred to the _root timeline and it runs the .swf application and kills the preloader application.

You need both files, and they should reside in the same directory (unless you change the import statement in the .fla file to reflect a different path).

Also, the application is designed such that both .swf files reside in the same directory (the preloader .swf and the .swf that is being loaded). Be sure to publish the preloader .swf to the right directory and the path to the file is specified in the fileName parameter in the .fla file.

Download InitialPreloader.fla (340.0K)

Download (1.2K)

Be sure to modify the ‘fileName’ parameter in the .fla file to properly reflect the .swf file you are trying to load!

— bkm