Adding an External File to the Bottom of the Display List

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.

Tutorial Elements

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.

 

Step One

Open a new Flash document and add a new layer.

Step Two

Name the upper layer Actions and the lower layer Content. Select frame one of the Content layer.

Step Three

Using the Oval tool, add a circle to the stage.

Step Four

Save your document and name it Main.fla. Add a new folder named Swf at the same level as your Main.fla file.

Step Five

Open a new document (File > New) named External.fla and save it in the Swf folder.

Step Six

Using the Rectangle tool, add a rectangle to the stage.

Step Seven

Publish your External movie by pressing Cmd/Return (PC - Ctrl/Enter).

Step Eight

Returning to the Main.fla file, Option double-click (PC - Alt double-click) frame one of the Actions layer.

Step Nine

Copy/Paste the following code to the ActionScript panel.

var loader01:Loader = new Loader();

loader01.load(new URLRequest("Swf/External.swf"));

addChildAt(loader01,0);

Step Ten

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.

 

Shutterfly 50 Free Prints 160x600