
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
322
|
Chapter 13: MovieClip Subclasses
the playhead stops at frame 1 (the Idle state) when the clip first loads. What about
stopping at frame 10 or 20 when the state of the clip changes to the Happy or Sad
state? Here is another case in which the implementation for the movie clip symbol
depends in part on the code you expect to write in the associated class. Because
setState( ) invokes MovieClip.gotoAndStop( ), we don’t need a separate stop( ) com-
mand at frames 10 and 20. If, however, setState( ) invoked gotoAndPlay( ) instead of
gotoAndStop( ), we’d need separate stop( ) commands in frames 10 and 20 of our
movie clip (or perhaps shortly thereafter if the state change included an animation).
With practice, you’ll learn how to design and coordinate a MovieClip subclass and its
associated movie clip symbol. The degree and type of integration required depends
on the responsibilities you assign to each element. As much as possible, you should
keep logic and data in the class and use the symbol for display only.
Linking AvatarSymbol to the Avatar Class
To associate the AvatarSymbol movie clip with the Avatar class, we must set the
AvatarSymbol’s so-called “AS 2.0 Class” in the Flash authoring tool, as follows:
1. Select the AvatarSymbol movie clip in AvatarDemo.fla’s Library.
2. Select the ...