Using Objects in ActionScript > Assigning a class to a movie clip

 

Assigning a class to a movie clip

To assign a custom class to a movie clip, you use the registerClass property of the Object class. The registerClass property takes arguments for a symbol linkage identifier (which identifies the movie clip) and a class. For example, this code assigns the class Ball to a movie clip that has the symbol linkage identifier myBall.

Object.registerClass("myBall",Ball);

The symbol linkage identifier must be enclosed in quotation marks.

You can also remove a custom class previously assigned to a movie clip, by entering null for the class argument.

Note: You assign a symbol linkage identifier to a symbol in the Linkage Properties dialog box (choose Linkage from the Library options menu). For more information, see Dynamically adding a movie clip or sound to the Stage.

 
To assign a custom class to a movie clip:

Use the following syntax:

Object.registerClass("symbolID",class);

 
To remove a custom class assigned to a movie clip:

Use the following syntax:

Object.registerClass("symbolID",null);