Flash CS4 ActionScript 3.0 Tutorial
How to Keep Track of All the Objects on the Flash Stage
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.
To really understand the Display List it is helpful to know how Flash treats various objects. A document with several Merge Shapes and/or Drawing Objects on the same layer counts as one level.
A Movie Symbol that contains several objects counts as one level. A text object with several letters counts as one level. The same text object, broken apart once takes up several levels.
In this example, several items are added to the stage so we can count the total Display List items.
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 Bottom of the 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.
Movie Symbol, Button Symbol, Merge Shape, Static Text Object
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 Merge Shape circle to the stage.
Add a Button Symbol to the stage.
Add a Movie Symbol to the stage.
Using the Text tool (Static Text), add the word Dog to the stage.
Select the word Dog and choose Modify > Break Apart (Cmd/b (PC - Ctrl/b)).
Option double-click (PC - Alt double-click) frame one of the Actions layer to open the ActionScript panel.
Copy/Paste the following code to the ActionScript panel.
Publish your movie by pressing Cmd/Return (PC - Ctrl/Enter). The Output panel displays the total number of levels in the Display List.
Dissecting the Code
The code at Step Ten traces the number of levels in the Display List and displays that value in the Output panel.
Notice that the text object counts as three levels because it was broken apart. Try adding additional symbols to the stage and notice how the count changes. The total children is six because you have an oval (1), a button (2), a movie (3) and three letters (6).
Counting Movie Symbols
Whenever you add a symbol to the stage it counts as one child. However, if you nest several Movie Symbols within a holder Movie Symbol, only the holder Movie Symbol is counted.