ActionScript 3.0 Design Patterns

(Chris Devlin) #1
The Pleasure of Doing Something Well | 7

MovieClipclass. ASpriteobject has no Timeline, but aMovieClipclass does. So


usingSprite objects save a bit of extra weight that the Timeline has.


Movie clip and button classes


In Flash CS3, MovieClip and Button objects you create using the Symbol dialog box


and store in the Library can be made available to work with ActionScript 3.0. Unlike


ActionScript 2.0 where MovieClip and Button symbols could be associated with a


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


entered into the Name window when the symbols are created becomes the class


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


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


The advantage of this new procedure is that the symbol objects can be instantiated


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


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


placed into a display array just like a dynamically generated object. Further, objects


contained within the MovieClip or Button can be addressed as a property just like


any other class.


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


example of this new way of creating a class with movie clips and buttons may be use-


ful to those new to Flash and experienced users alike. The following steps walk you


through this new feature:



  1. Open a new Flash document and save it asrocket.fla.

  2. Select Insert➝New Symbol from the menu bar to open the Create New Symbol
    Dialog box. EnterRocketin the Name window, and Click OK to enter the Sym-
    bol Edit Mode.

  3. In the Symbol Edit Mode, draw a rocket on the stage with the dimensions
    W=89, H=14, as shown in Figure 1-2. Once finished, position the drawing at
    X=0, Y=0. Click the Scene 1 icon to exit the Symbol Edit Mode.


Figure 1-1. Document class window

Free download pdf