Creating Movie Clips

We covered how to create a movie clip manually back in Chapter 5, "Symbols and the Library," but we will review it quickly here.

Creating Movie Clips Manually

To create a Movie Clip symbol manually, follow these steps:


Choose Insert, New Symbol.


In the Create New Symbol dialog box, give the symbol a symbol name, choose Movie Clip as the behavior, and then click OK.


Now you are inside the newly created movie clip.

That was pretty simple; you just created a movie clip manually. Now if you want to use it, drag an instance of it from the library onto the stage and give it an instance name.


Although technically you do not need to give every instance of a movie clip object an instance name unless you plan to refer to it with ActionScript, it is good practice to do so. Also remember that you cannot duplicate instance names in the same timeline or errors will occur.

Creating movie clips manually is not the only way to create them. You can also create them on-the-fly with ActionScript.

Creating Movie Clips with ActionScript

Since the MX version of Flash, users have been able to create movie clips with ActionScript. Before then, when you wanted an empty movie clip on the stage, you would have to create one manually, drag it onto the stage, and then give it an instance name.

To create empty movie clips in ActionScript, use the createEmptyMovieClip() method, which looks like this:

 movieClip.createEmptyMovieClip(instanceName, depth); 

The parameters of this method are as follows:

  • movieClip The instance name of the movie clip where the empty clip will be created.

  • instanceName This is a string literal that represents the instance name of the movie clip being created.

  • depth This is a numerical value that represents the stacking order of the movie clip being created (more on depth later in this chapter).

That is the basic layout of the createEmptyMovieClip() method. The next example shows how to implement it.


Create a new Flash document.


In the first frame of the main timeline, place these actions:

 //this refers the main timeline this.createEmptyMovieClip("sample_mc", 1); 


Now test the movie by choosing Control, Test Movie.


Notice that when the movie runs, there isn't anything on the stage. This is because we created an empty movie clip; there is nothing inside it, but you can tell it's there.

When you're in the test movie screen, choose Debug, List Objects, and you should see in the Output panel something similar to Figure 13.1.

Figure 13.1. Using the List Objects option under Debug, you can see the movie clip you created via ActionScript.

The movie is listed in the Output panel.

Now that you have seen the different ways to create movie clips, continue on to see how to manipulate them.

Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319 © 2008-2017.
If you may any questions please contact us: