
Where are my display objects?
Before, the Stage class in AS2 is treated as a class whose properties are all static, but with AS3 the new and better Stage class is now a display object. Both making the stage class the main drawing area and where flash content is shown. Basically, just think of it as a practical stage, all actors and props are all objects on display and those who are backstage are objects which are simply not included in the stage yet.
The Stage is a singleton class whereas there can only be one instance of it (imagine watching a play where there are 2 or more stages, its just impossible). Even if you add multiple instances of display objects to the display list, the stage property of each display object still refers to the same Stage object (that goes for loaded SWF files too).
Did you know that the stage is not globally accessible – you can’t call it or reference it from anywhere (unless manually referenced in a variable of course). The simplest way to do so is to use the
stageproperty from any of your display objects which were added to the display list.
Yes, you heard it right from “any” display object, but take note, only if it is already added to the display list. It doesn’t matter if your display object is a child of another display object or how far the display heirarchy it is, as long as it is included in the display list.
Don’t confuse yourself with “Stage” (with capital “S”) and “stage” (with small caps). “Stage” refers to the class flash.display.Stage and “stage” is it’s instance.
Just remember, from a common coding convention: classes begin with capital letters and variables don’t.
If the display object is removed or not yet added from the display list the stage property is just set to null.






( 3.67 / 5 from 3 votes )


•