Using Flash’s Built-in Composite Structure: the Display List | 239
ences the root node of the airplane. The whole composite plane structure plane is
then added to the display object container linked to theMainclass (line 18). Because
theMainclass is thedocument classof the Flash document, the airplane is added to
thestage, which is the root node of the display list.
Figure 6-9. Hierarchical tree structure of the airplane
Example 6-25. Main.as
1 package
2 {
3 import flash.display.Sprite;
4
5 /**
6 * Main Class
7 * @ purpose: Document class for movie
8 */
9 public class Main extends Sprite
10 {
11 private var airPlane:Composite;
12
13 public function Main( )
14 {
15 // create airplane
16 airPlane = new Composite(0.0);
17 airPlane.x = 250; airPlane.y = 100;
18 addChild(airPlane);
19
20 // add fuselage
21 var fuselage:Composite = new Fuselage(1000, 0)
22 airPlane.addChild(fuselage);
23
24 // add main wing on the left (port side)
25 var rightWing:Composite = new MainWing(200, 0);
26 rightWing.x = 20; rightWing.y = 50;
27 fuselage.addChild(rightWing);
28
29 // add main wing on the right (starbord side)
30 var leftWing:Composite = new MainWing(200, 0);
airplane
fuselage
Main wing Main wing Tail wing Tail wing
engine engine