Working with Movie Clips and Buttons > Using actions and methods to control movie clips > Dynamically creating an empty movie clip

 

Dynamically creating an empty movie clip

To create an empty movie clip on the Stage while a movie plays, use the createEmptyMovieClip method of the MovieClip object. This method creates a movie clip as a child of the clip that calls the method. The registration point for a newly created empty movie clip is the upper left corner. Although the createEmptyMovieClip method behaves similarly to attachMovie, you don't need to provide a linkage identifier because you aren't adding a symbol from the library.

 
To create an empty movie clip:

1

Select a frame, button, or movie clip to which to assign the action.

2

Choose Window > Actions to open the Actions panel if it isn't already open.

3

In the Actions toolbox (at the left of the Actions panel), click the Objects category, the Movie category, the MovieClip category, and the Methods category, and double-click createEmptyMovieClip.

4

For the object parameter, enter the instance name of a movie clip on the Stage, or click the Insert Target Path button to browse to an instance.

5

Enter values for the following parameters:

For instanceName, specify an identifier.

For depth, enter the level at which the duplicate movie will be attached to the movie clip. Each created movie has its own stacking order, with level 0 as the level of the originating movie. Newly created movie clips are always on top of the original movie clip. Here is an example:

myMovieClip.createEmptyMovieClip("newMC", 10);