Basics of movie clips

Introduction to working with movie clips

Movie clips are a key element for people who create animated content with the Flash authoring tool and want to control that content with ActionScript. Whenever you create a movie clip symbol in Flash, Flash adds the symbol to the library of that Flash document. By default, this symbol becomes an instance of the MovieClip class, and as such has the properties and methods of the MovieClip class.

When an instance of a movie clip symbol is placed on the Stage, the movie clip automatically progresses through its timeline (if it has more than one frame) unless its playback is altered using ActionScript. It is this timeline that distinguishes the MovieClip class, allowing you to create animation through motion or shape tweens through the Flash authoring tool. By contrast, with a display object that is an instance of the Sprite class, you can create animation only by programmatically changing the object's values.

In previous versions of ActionScript, the MovieClip class was the base class of all instances on the Stage. In ActionScript 3.0, a movie clip is only one of many display objects that can appear on the screen. If a timeline is not necessary for the function of a display object, using the Shape class or Sprite class in lieu of the MovieClip class may improve rendering performance. For more information on choosing the appropriate display object for a task, see Choosing a DisplayObject subclass.

Common movie clip tasks

The following common movie clips tasks are described in this chapter:

Important concepts and terms

The following reference list contains important terms used in this chapter:

Working through in-chapter examples

As you're working through the chapter, you may want to test some of the example code listings for yourself. Because this chapter is about working with movie clips in ActionScript, essentially all the code listings in this chapter are written with the idea of manipulating a movie clip symbol that has been created and placed on the Stage. Testing the sample will involve viewing the result in Flash Player to see the effects of the code on the symbol. To test the code listings in this chapter:

  1. Create an empty Flash document.
  2. Select a keyframe in the timeline.
  3. Open the Actions panel and copy the code listing into the Script pane.
  4. Create a movie clip symbol instance on the Stage. For example, draw a shape, select it, choose Modify > Convert to symbol, and give the symbol a name.
  5. With the movie clip selected, in the Property inspector, give it an instance name. The name should match the name used for the movie clip in the example code listing--for example, if the code listing manipulates a movie clip named myMovieClip, you should name your movie clip instance myMovieClip as well.
  6. Run the program using Control > Test Movie.

    On the screen you will see the results of the code manipulating the movie clip as specified in the code listing.

Other techniques for testing example code listings are explained in more detail in Testing in-chapter example code listings.


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000210.html