
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
376
|
Chapter 14: Movie Clip Subclasses and Components
Creating the Library Symbol
Before returning to the code in Example 14-1, let’s set up our movie’s assets. Each
movie clip subclass is associated with a movie clip symbol stored in the Library. To
create instances of the subclass programmatically, we must export the symbol for use
with ActionScript. Here are the steps we follow to create and export a movie clip
symbol for our Ball class:
1. Create a movie clip symbol, named ballSymbol, that contains a circle shape.
2. In the Library, select ballSymbol.
3. From the Library’s pop-up Options menu, select Linkage. The Linkage Proper-
ties dialog box appears.
4. Select the Export For ActionScript checkbox.
5. In the Identifier field, type
ballSymbol.
6. Click OK.
Next, we’ll create the Ball constructor function that will be invoked automatically
every time an instance of ballSymbol is created.
main( );
// Function: main( )
// Desc: Application entry point
function main ( ) {
// Create an object whose properties will be used
// as the Ball constructor's parameters
var ballParams = new Object( );
ballParams.radius = 10;
ballParams.ballColor = 0xFF0000;
ballParams.x = 250;
ballParams.y = 250;
ballParams.velocity = {x:12, y:4};
// Assign the ballParams object to a single property
// of initObj ...