Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 169

Programming actionscript 3.0
Table of Contents

Advertisement

myTextField.text = "hello";
this.root.addChild(myTextField);
In this code sample,
points to the MovieClip display object container that
this.root
contains the code. In your actual code, you may specify a different container.
Use the
method to add the child to a specific position in the child list of the
addChildAt()
display object container. These zero-based index positions in the child list relate to the
layering (the front-to-back order) of the display objects. For example, consider the following
three display objects. Each object was created from a custom class called Ball.
The layering of these display objects in their container can be adjusted using the
method. For example, consider the following code:
addChildAt()
ball_A = new Ball(0xFFCC00, "a");
ball_A.name = "ball_A";
ball_A.x = 20;
ball_A.y = 20;
container.addChild(ball_A);
ball_B = new Ball(0xFFCC00, "b");
ball_B.name = "ball_B";
ball_B.x = 70;
ball_B.y = 20;
container.addChild(ball_B);
ball_C = new Ball(0xFFCC00, "c");
ball_C.name = "ball_C";
ball_C.x = 40;
ball_C.y = 60;
container.addChildAt(ball_C, 1);
After executing this code, the display objects are positioned as follows in the
container
DisplayObjectContainer object. Notice the layering of the objects.
Working with display objects
169

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents