10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

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.

Figure 6-9. Hierarchical tree structure of the airplane<br />

ences the root node of the airplane. The whole <strong>com</strong>posite plane structure plane is<br />

then added to the display object container linked to the Main class (line 18). Because<br />

the Main class is the document class of the Flash document, the airplane is added to<br />

the stage, which is the root node of the display list.<br />

Example 6-25. Main.as<br />

Main wing<br />

engine<br />

Main wing<br />

engine<br />

airplane<br />

fuselage<br />

Tail wing<br />

Tail wing<br />

1 package<br />

2 {<br />

3 import flash.display.Sprite;<br />

4<br />

5 /**<br />

6 * Main Class<br />

7 * @ purpose: Document class for movie<br />

8 */<br />

9 public class Main extends Sprite<br />

10 {<br />

11 private var airPlane:Composite;<br />

12<br />

13 public function Main( )<br />

14 {<br />

15 // create airplane<br />

16 airPlane = new Composite(0.0);<br />

17 airPlane.x = 250; airPlane.y = 100;<br />

18 addChild(airPlane);<br />

19<br />

20 // add fuselage<br />

21 var fuselage:Composite = new Fuselage(1000, 0)<br />

22 airPlane.addChild(fuselage);<br />

23<br />

24 // add main wing on the left (port side)<br />

25 var rightWing:Composite = new MainWing(200, 0);<br />

26 rightWing.x = 20; rightWing.y = 50;<br />

27 fuselage.addChild(rightWing);<br />

28<br />

29 // add main wing on the right (starbord side)<br />

30 var leftWing:Composite = new MainWing(200, 0);<br />

Using Flash’s Built-in Composite Structure: the Display List | 239

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

Saved successfully!

Ooh no, something went wrong!