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

Create successful ePaper yourself

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

The following steps guide you through the process of preparing the two MovieClip<br />

classes in the Flash IDE and setting the stage as a “soul chart.”<br />

1. Open a new Flash document file, type in Soul in the Document class window,<br />

and save the file as SoulChart.fla.<br />

2. Add a layer to the existing layer, and name the top layer, Labels and the bottom<br />

layer “Lines.” (Say that last sentence fast three times!)<br />

3. Select Insert ➝ New Symbol from the menu bar. Type Angel in the Name window,<br />

and click the Export for <strong>ActionScript</strong> checkbox. Click OK. You are now in<br />

the Symbol Edit Mode. (Be sure to capitalize the “A” in “Angel” because this is a<br />

class name.)<br />

4. In the Symbol Edit window, draw or import an image of an angel.<br />

5. Click the Text icon in the Tools panel, and select Dynamic Text for the type of<br />

text. In the Properties panel, provide the instance name soul_txt for the dynamic<br />

text object.<br />

6. Exit the Symbol Edit Mode by clicking the Scene 1 icon. You should now see a<br />

movie clip icon in the Library named “Angel.”<br />

7. Repeat steps 3 to 6, substituting “Devil” for “Angel.” Once you’re finished, you<br />

should see both Devil and Angel movie clip icons in the Library panel.<br />

8. Click the Lines layer and add 11 horizontal lines and one vertical line as shown<br />

in Figure 4-7. Lock the layer.<br />

9. Click the Labels layer, number the lines from 0 to 100, and place a “Good” and<br />

“Evil” label at the top of the stage as shown in Figure 4-7. Lock the layer and<br />

save the file once again.<br />

By adding and removing the <strong>com</strong>ment lines in the Soul.as file, you can change the<br />

vertical positions of the angel and devil images. You may have to make some adjustments<br />

depending on the size of your angel and devil movie clips and/or if you change<br />

the default size of the stage from 550 by 400.<br />

Dynamic Selection of Concrete Components and<br />

Decorations: A Hybrid Car Dealership<br />

Up to this point, the examples have focused on different dimensions of the Decorator<br />

design pattern, with the emphasis on how the different elements in the Decorator<br />

design pattern can be used with different <strong>com</strong>ponents and decorations. Both<br />

concrete and abstract output has shown different ways to display information, but<br />

no example has illustrated how to input data dynamically. This Decorator example<br />

uses the case of selecting automobiles and their options to illustrate how to dynamically<br />

input data for both decorators and concrete <strong>com</strong>ponents.<br />

164 | Chapter 4: Decorator Pattern

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

Saved successfully!

Ooh no, something went wrong!