Initializing movie clips with class assignment

To make sure that the class assignment occurs before the symbol appears on Stage, you can place the registerClass method on the first frame of the movie clip within an #initClip/#endInitClip code block, as shown below.

// On frame 1 script of the movie clip with identifier string "symbolID":
#initClip
	Object.registerClass("symbolID", className);
#endInitClip

In fact, this is exactly what is done automatically (by the compiler) when you assign a class with the ClassName field in the Linkage Properties dialog. The compiler inserts, on the first frame of the movie clip to which you assigned the class, an #initClip/#endInitClip code block containing the apprpropriate Object.registerClass() method call.

For example, suppose you have a movie clip with a symbol linkage ID name of Ball, and you entered animation.Spin in the ClassName field in the Linkage Properties dialog for that symbol. Upon export to SWF, the compiler would add the following ActionScript to the first frame of the Ball movie clip.

#initClip
	Object.registerClass("Ball", animation.Spin);
#endInitClip

For more information about #initClip and #endInitClip see .

Controlling order of execution for class assignmentsYou place actions to assign a class on the first frame of a movie clip symbol. In the normal order of execution in ActionScript, the actions assigning the class would be executed at the end of the frame. However, in most circumstances you will want the class assignment to be executed in front of the frame, before the movie clip is instantiated, so that properties of the class are enabled as soon as the movie clip appears. In order to execute the class assignment actions in front of the frame, you must add the tags #initclip and #endinitclip at the beginning and end of the actions.

To execute a class assignment in front of the frame in which the code is placed: