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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Display programming<br />

import flash.display.*;<br />

import flash.text.TextField;<br />

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

myText.text = "Bu<strong>en</strong>os dias.";<br />

this.addChild(myText);<br />

Wh<strong>en</strong> you add any visual elem<strong>en</strong>t to the Stage, that elem<strong>en</strong>t becomes a child of the Stage object. The first SWF file<br />

loaded in an application (for example, the one that you embed in an HTML page) is automatically added as a child of<br />

the Stage. It can be an object of any type that ext<strong>en</strong>ds the Sprite class.<br />

Any display objects that you create without using ActionScript—for example, by adding an MXML tag in a Flex MXML<br />

file or by placing an item on the Stage in Flash Professional—are added to the display list. Although you do not add<br />

these display objects through ActionScript, you can access them through ActionScript. For example, the following<br />

code adjusts the width of an object named button1 that was added in the authoring tool (not through ActionScript):<br />

button1.width = 200;<br />

Working with display object containers<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

If a DisplayObjectContainer object is deleted from the display list, or if it is moved or transformed in some other way,<br />

each display object in the DisplayObjectContainer is also deleted, moved, or transformed.<br />

A display object container is itself a type of display object—it can be added to another display object container. For<br />

example, the following image shows a display object container, pictureScre<strong>en</strong>, that contains one outline shape and<br />

four other display object containers (of type PictureFrame):<br />

Last updated 6/6/2012<br />

159

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

Saved successfully!

Ooh no, something went wrong!