Loading and Controlling Flash Content

One of the best ways to improve the download time of Flash is to only load what is needed, when it is needed.

Flash allows you to load external content, only calling the content you need, as you need it. This keeps the initial download small. What needs to be done if figured out what needs to load initially, and what can be loaded at a later time.

If/When dealing with a flash based website, the menu, and background have to be loaded initially. However, the "pages" of the Flash site don't need to be loaded until it is completed.

Loading External SWF Files

You will need to use a Loader object to bring in the external files.

var myLoader:Loader=new Loader();

Then you will need to create a listener for your button objects, so that when they are pressed, the actionscript will then call the myLoader object.

Loading the external file requires that you get a URLRequest object to identify the file. The files, as shown in the book, are in the same directory as the main flash document.

You can position your files in different locations, however, most people leave them at the deafult location.

Loading External Images

This is done the same way as th external SWF. However, instead of loading the .swf file in the URLRequest object, you specify a .jpg, or other supported image file.