You want to add a new display object to the display list so it appears on-screen.
Use the addChild() and addChildAt() methods from the DisplayObectContainer class.
The Flash Player is composed of two main pieces that function together to form a cohesive unit, the ActionScript Virtual Machine (AVM) and the Rendering Engine. The AVM is responsible for executing ActionScript code, and the Rendering Engine is what draws objects on-screen. Because the Flash Player is composed of these two main pieces, drawing an object on the screen is a two-step process:
The display object needs to be created in the ActionScript engine.
The display object is then created in the rendering engine and drawn on-screen.
The first step is done by using the
new operator to create an instance of the
display object. Any object that is going to be added to the display
list must be either a direct or indirect subclass of DisplayObject, such as Sprite, MovieClip,
TextField, or a custom class you create
(according to Recipe 6.4).
To create a TextField instance
you would use the following code:
var hello:TextField = new TextField();
The preceding line of code creates a TextField display object in the AVM, but the object is not drawn on the screen yet because the object doesn’t exist in the Rendering Engine. To create the object in the Rendering Engine, the object needs to be added to the display list hierarchy. This can be done by calling the addChild() ...