Adding an External File to the Bottom of the Display List
Flash CS4 ActionScript 3.0 Tutorial
How to Place an Object on the Bottom Level of Display List in Flash
The Display List plays an important role in your Flash files. It keeps track of the all the objects on the stage at any given time. You can import external files or files from the Library and specify that they be added to the top, bottom or at a specific level.
It is easy to confuse the levels of the Display List and the layers in your Flash document. As you add objects to your layers, they are added to the Display List. It is possible to add external files at specific levels of the Display List or remove an object at a particular level.
In this example we will add an external file to the bottom of the Display List using the addChildAt() statement.
For more information on Display Lists, see topics, Adding a File to a Specific Level of a Display List, Adding an External File to the Top of the Display List, Checking the Display List Contents and Removing a File from the Display List.
An external swf file named External.swf located in a folder named Swf. The folder should be at the same level at the host swf file.
Open a new Flash document and add a new layer.
Name the upper layer Actions and the lower layer Content. Select frame one of the Content layer.
Using the Oval tool, add a circle to the stage.
Save your document and name it Main.fla. Add a new folder named Swf at the same level as your Main.fla file.
Open a new document (File > New) named External.fla and save it in the Swf folder.
Using the Rectangle tool, add a rectangle to the stage.
Publish your External movie by pressing Cmd/Return (PC - Ctrl/Enter).
Returning to the Main.fla file, Option double-click (PC - Alt double-click) frame one of the Actions layer.
Copy/Paste the following code to the ActionScript panel.
var loader01:Loader = new Loader();
Publish your movie by pressing Cmd/Return (PC - Ctrl/Enter). The external file is added to the stage below the oval object.
Dissecting the Code
The code at Step Nine adds a new Loader variable named loader01. The next line fills the loader with the External.swf file.
The final line adds the loader01 to the stage. By using the addChildAt() method and specifying the level to be zero, the external file is added to the bottom level. The lowest level in the display list is level 0.