13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Display programming<br />

A. A shape defining the border of the pictureScre<strong>en</strong> display object container B. Four display object containers that are childr<strong>en</strong> of the<br />

pictureScre<strong>en</strong> object<br />

In order to have a display object appear in the display list, you must add it to a display object container that is on the<br />

display list. You do this by using the addChild() method or the addChildAt() method of the container object. For<br />

example, without the final line of the following code, the myTextField object would not be displayed:<br />

var myTextField:TextField = new TextField();<br />

myTextField.text = "hello";<br />

this.root.addChild(myTextField);<br />

A B<br />

In this code sample, this.root points to the MovieClip display object container that contains the code. In your actual<br />

code, you may specify a differ<strong>en</strong>t container.<br />

Use the addChildAt() method to add the child to a specific position in the child list of the display object container.<br />

These zero-based index positions in the child list relate to the layering (the front-to-back order) of the display objects.<br />

For example, consider the following three display objects. Each object was created from a custom class called Ball.<br />

Last updated 6/6/2012<br />

160

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!