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 1-1. Document class window<br />

MovieClip class. A Sprite object has no Timeline, but a MovieClip class does. So<br />

using Sprite objects save a bit of extra weight that the Timeline has.<br />

Movie clip and button classes<br />

In Flash CS3, MovieClip and Button objects you create using the Symbol dialog box<br />

and store in the Library can be made available to work with <strong>ActionScript</strong> <strong>3.0</strong>. Unlike<br />

<strong>ActionScript</strong> 2.0 where MovieClip and Button symbols could be associated with a<br />

class, with Flash CS3, they can be made into classes themselves. The object’s name<br />

entered into the Name window when the symbols are created be<strong>com</strong>es the class<br />

name for the object. (In past versions, references to a movie clip are made through an<br />

instance name. You can still make those references, but in a different context.)<br />

The advantage of this new procedure is that the symbol objects can be instantiated<br />

just like any other class through the code, as long as the symbols are in the Library.<br />

You don’t have to place them on the stage. They can be dynamically instantiated and<br />

placed into a display array just like a dynamically generated object. Further, objects<br />

contained within the MovieClip or Button can be addressed as a property just like<br />

any other class.<br />

While this book is in no way an introduction to Flash CS3, walking through one<br />

example of this new way of creating a class with movie clips and buttons may be useful<br />

to those new to Flash and experienced users alike. The following steps walk you<br />

through this new feature:<br />

1. Open a new Flash document and save it as rocket.fla.<br />

2. Select Insert ➝ New Symbol from the menu bar to open the Create New Symbol<br />

Dialog box. Enter Rocket in the Name window, and Click OK to enter the Symbol<br />

Edit Mode.<br />

3. In the Symbol Edit Mode, draw a rocket on the stage with the dimensions<br />

W=89, H=14, as shown in Figure 1-2. Once finished, position the drawing at<br />

X=0, Y=0. Click the Scene 1 icon to exit the Symbol Edit Mode.<br />

The Pleasure of Doing Something Well | 7

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

Saved successfully!

Ooh no, something went wrong!