The "Display List" is the hierarchy of graphical objects in your movie to be displayed on screen at runtime. The hierarchy is created via parent-child relationship between objects. Parts of this hierarchy are created automatically by the Flash Player. For example, the top object in the hierarchy, called the Stage, as well as the MainTimeline are created by the Player. Other parts you create knowingly or unkowingly when you draw objects at authoring time. When you create parent-child relationships between objects via "addChild" method in your ActionScript 3 program, you consciously create and control parts of the Display List.
Here is the Display List of our "solar system" movie shown on the previous page.
As you see, when you draw or create text fields during authoring time, your are adding children of the MainTimeline to the Display List. The Stage (discussed in detail on the next page) has usually only one child, the MainTimeline. The children that you are creating at authoring time are added to MainTimeline on depths 0 to (number of children)-1. No depths are skipped or unoccupied. You can create display objects programmatically, like the sprite "sun" in our solar system, and add them to the Display List via:
The addChild method evoke above adds "sun" to the List as a child of the MainTimeline at the next available depth. "this" in the above context refers to the MainTimeline.
It is often hard to figure out the depth, the order, and even the number of children created at authoring time. For example, the two lines that we drew, constitute one child of the MainTimeline. It is much easier to keep track of children created programatically, placed in a programmaticaly created Sprite or a MovieClip. That is what we will do in our upcoming tutorial on depths management.
To figure out what object has what children, add the following code at the end of the script in the fla file from the previous page, children.fla:
trace("Number of children of Stage: ");
trace("What are children of Stage: ");
trace("What does the keyword this refer to? ");
trace("Number of children of MainTimeline: ");
trace("What are children of MainTimeline: ");
trace("How many children does the sprite sun have: ");
When you test the movie, the Output window reads:
Number of children of Stage:
What are children of Stage:
What does the keyword this refer to?
Number of children of MainTimeline:
What are children of MainTimeline:
How many children does the sprite sun have:
The Stage has one child, MainTimeline. The MainTimeline has 5 children: the three static text boxes, the two lines combined into one child (a shape), and one sprite which is our programmatically created "sun".
- Flash CS3 file children_test_1.fla
Download the fla file with the above code and test it.
What exactly is the Stage? How does "Stage" differ from "stage"? We discuss this question in the next section.