
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
MovieClip Sub-Subclasses
|
387
/*
* Instance Methods
*/
/*
* Method: SomeClass.someMethod( )
* Desc: Short description
*
* Params:
* param -Short description
*
*/
SomeClass.prototype.someMethod = function (param) {
trace("someMethod invoked with parameter of: " + param);
};
#endinitclip
The following code shows example usage of the SomeClass template. To see a manu-
ally created SomeClass instance, download the componentTemplate.fla file from the
Code Depot.
// Create an instance
var initObj = new Object( );
initObj.cp_param1 = 15;
initObj.cp_param2 = "Hello world";
this.attachMovie("someClassSymbol", "someClassInstance", 1, initObj);
MovieClip Sub-Subclasses
Just like a regular class, a MovieClip subclass can itself be extended by another sub-
class. When a parent class is defined outside of its corresponding movie clip symbol
(as in the very first Ball example in this chapter), its child subclass can be defined by:
• Setting the child’s prototype to a new parent instance
• Registering the child class with its symbol via Object.registerClass()
Remember also to invoke the parent’s constructor function from the child construc-
tor. For example, the following code shows how to create a subclass, Baseball, of our
existing class, Ball:
// Baseball class constructor
org.moock.Baseball = function ( ...