
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
380
|
Chapter 14: Movie Clip Subclasses and Components
In plain English, this tells the interpreter, “when a ballSymbol instance is created,
invoke the org.moock.Ball() constructor, with the
this keyword pointing to the new
ballSymbol instance.”
The new MovieClip() statement only establishes a class as a subclass of
the MovieClip class (i.e., it merely establishes inheritance). It cannot be
used to create new movie clips for use in a movie! Use attachMovie(),
duplicateMovieClip(),orcreateEmptyMovieClip() to create new
instances of movie clips or movie clip subclasses, such as Ball.
For more information on Object.registerClass(), see the Language Reference.
Packaging Subclass Code and Library
Symbols Together
With our superclass assigned, we’ve created a fully functioning MovieClip subclass,
Ball. We can add methods and properties to it via
Ball.prototype, just as we would
with any class (as shown in Example 14-1). However, suppose we wanted to share
our Ball class with another developer. We might sensibly put our class in an external
.as file and tell the developer to
#include the file. But we’d also have to tell her to
make a Library symbol for the class and export that symbol as “
ballSymbol”. If the
developer doesn’t export the symbol, or if she exports it with the wrong linkage iden-
tifier, ...