Click to Show Lecture Notes

Flash MX Movie Clip Actions...

You've just placed Actions in keyframes, now let's see how they work with Movie Clips.

Actions on Movie Clips are powerful, you'll have to fully study this feature to really learn it, but you can get a taste of it in a practice session on this page. There are books written only for ActionScripts, so you can expect to spend some time learning how to use them in the future.

Place Actions On A Movie Clip InstancePlace Actions On A Movie Clip Instance

Place Actions On A Movie Clip Instance

  1. Choose Window > Scene (Shift F12), and add a new scene, rename this scene MyAnimation. Create a Movie Clip inside the new scene that contains several frames and some kind of animation inside the clip (so we can see whether it's playing).
  2. Scene 1 should remain empty for now.
    Adding a Scene to the Movie
  3. Click on Scene One, there should only be one keyframe in this scene. Open the Library to find your Movie Clip.


  4. Drag this Movie Clip onstage and test the movie (to verify it's animating). Remember your main timeline should have only one frame.


  5. Back in Flash, select the instance of the Movie Clip onstage and open the Actions panel. notice that almost all the Actions in the Toolbox List are available (that is, they're not grayed out).


  6. From the plus button select Actions > Movie Control > Stop. Notice that Actions attached to Movie Clip instance have to be wrapped inside an onClipEvent. The default clip event is load, so you should see something like the following image.

  7. Adding an onClipEvent to the Movie
  8. Test the movie now and, when the Movie Clip loads, it stops. Another way to create the same effect is to put a stop Action on the first keyframe inside the master Movie Clip.
  9. There is nothing really wrong with the above technique, but a stop inside the master Movie Clip means every instance will exhibit this behavior. Placing the Action on one instance, affects just that one instance.

    You will add two more Actions that respond to the mouse down and mouse up events. When the user clicks (mouse down), the Movie Clip should start to play. When he stops clicking (mouse up), the Movie Clip should stop.

    TIP: If the line currently selected in your script is within the curly braces, you won't be adding another clip event, because you can't put an event inside an event. Remember: Every time you add an Action, Flash will try to put the Action right below the line currently selected in your script.

  10. Drag the onClipEvent script (from the Toolbox section under Actions, Movie Clip Control) below the ending curly brace.
  11. (Note: You could have selected the last line and then select the plus button, Actions, Movie Control, onClipEvent as well, it's your choice on how to add these Action.)



  12. Before you add more clip events, drag a stop Action to appear right underneath the first line in the clip event you added in the last step. To add more clip events, drag a play Action (from the Toolbox section) below the last line in your script. It will automatically be wrapped inside an onClipEvent load script.


  13. The way your script is written now doesn't make a whole lot of sense because you have three versions of onClipEvent (load). Leave the first one you created alone. Click the first line of the second event (the one with stop inside). With this line selected, you can change the parameters of the clip event to respond to mouse up instead of load. The last event should start with a clip event of mouse down. (Check your script against the image below.)


  14. Test the movie. It's actually pretty sophisticated, despite the simplicity of the script. Go back and re-read the script to see for yourself.


  15. Hide Practice Session 1

There are a few important things to note about this session. First, the clip events mouse down and mouse up respond to any mouse click—not just clicks on the clip itself. If you want something that responds to clicks right on a graphic, using a regular button is easiest. (That's the topic of the next page.)

The basic things to remember are that just like buttons, Actions on clip instances are wrapped inside events. Buttons respond to the on event while Movie Clips respond to the onClipEvent. Finally, Actions attached to clip instances affect only the particular instance to which they're attached.

Page Updated on March 2, 2003