The Movie Clip Symbol


We have saved the best for last in this chapter because the movie clip has it all. Movie clips have an independent timeline in that their timeline is not dependent on the main timeline; therefore, their play head can move in sync or out of sync with the main play head. Also, movie clips can have ActionScript within their own timeline and/or have ActionScript in their object actions. The main timeline itself is a movie clip, although you won't find it in the Library panel with the others. Movie clips are so powerful, in fact, that an entire chapter, Chapter 13, "The Movie Clip Objects." has been devoted to them. But we will still run through the major points in this chapter.

Making a Movie Clip symbol is the same as making the other symbols, but you choose a different behavior.

1.

Create a new Flash document and save it as myFirstMovieClip.fla.

2.

Draw a circle in the center of the stage about 75x75 and give it a red fill color (0xff0000) like Figure 5.8.

Figure 5.8. Movie Clip symbols are the most reusable symbol Flash has to offer.


3.

Select the circle, both stroke and fill, and choose Modify, Convert to Symbol (F8).

4.

In the Convert to Symbol dialog box, give it a symbol name of circleMC, choose Movie Clip for the behavior, and click OK.

If you tested the movie right now, the square would be there. But if that was all you were going to do, you could have used a graphic. Instead, you will go back into the movie clip and add some ActionScript to make the circle interactive.

5.

Back on the main timeline, select the circle movie and open the Actions panel by choosing Window, Actions (F9).

6.

In the object actions of the circle, place the following code:

 onClipEvent(mouseDown){  //if the user clicks the circle  if(hitTest(_root._xmouse,_root._ymouse)){    //drag the circle    this.startDrag(false);  } } //when the user lets go onClipEvent(mouseUp){  //stop dragging the circle  stopDrag(); } 

Do not worry if the code is new to you, it will be covered in later chapters, but the code is necessary so that you can see the power of movie clips.

Test the movie at this point, and you will see that if you click the circle and move the mouse, the circle will drag. Let go and the movie will stop dragging.

That covers the basics of movie clips, as well as the other two symbols. The next step is to see where they are stored.




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net