Flash CS3 Documentation |
|||
| Programming ActionScript 3.0 > Display programming > Basics of display programming | |||
Each application built with ActionScript 3.0 has a hierarchy of displayed objects known as the display list. The display list contains all the visible elements in the application. Display elements fall into one or more of the following groups:
The Stage is the base container of display objects. Each application has one Stage object, which contains all on-screen display objects. The Stage is the top-level container and is at the top of the display list hierarchy:
Each SWF file has an associated ActionScript class, known as the main class of the SWF file. When Flash Player opens a SWF file in an HTML page, Flash Player calls the constructor function for that class and the instance that is created (which is always a type of display object) is added as a child of the Stage object. The main class of a SWF file always extends the Sprite class (for more information, see Advantages of the display list approach).
You can access the Stage through the stage property of any DisplayObject instance. For more information, see Setting Stage properties.
In ActionScript 3.0, all elements that appear on screen in an application are types of display objects. The flash.display package includes a DisplayObject class, which is a base class extended by a number of other classes. These different classes represent different types of display objects, such as vector shapes, movie clips, and text fields, to name a few. For an overview of these classes, see Advantages of the display list approach.
Display object containers are special types of display objects that, in addition to having their own visual representation, can also contain child objects that are also display objects.
The DisplayObjectContainer class is a subclass of the DisplayObject class. A DisplayObjectContainer object can contain multiple display objects in its child list. For example, the following illustration shows a type of DisplayObjectContainer object known as a Sprite that contains various display objects:
In the context of discussing display objects, DisplayObjectContainer objects are also known as display object containers or simply containers.
Although all visible display objects inherit from the DisplayObject class, the type of each is of a specific subclass of DisplayObject class. For example, there is a constructor function for the Shape class or the Video class, but there is no constructor function for the DisplayObject class.
As noted earlier, the Stage is a display object container.
Since so much of ActionScript programming involves creating and manipulating visual elements, there are numerous tasks that are related to display programming. This chapter describes common tasks that apply to all display objects, including:
Later chapters in this manual describe additional tasks for working with display objects. These tasks include both tasks that apply to any display object and tasks associated with specific types of display objects:
The following reference list contains important terms that you will encounter in this chapter:
As you're working through the chapter, you may want to test some of the example code listings for yourself. Because this chapter is about creating and manipulating visual content, essentially all the code listings in this chapter create visual objects and display them on the screen; testing the sample will involve viewing the result in Flash Player rather than viewing values of variables as in previous chapters. To test the code listings in this chapter:
You will see the results of the code displayed on the screen, and any trace() function calls will display in the Output panel.
Techniques for testing example code listings are explained in more detail in Testing in-chapter example code listings.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000142.html