H  32  32.1  33  34  35  36 

Hands-On: Flash MX 2004 ActionScripting

Exercise 35: Add Buttons to an Animation

Use the previous animation file: MX04_ActionScripting-Loops.fla so we can let the user stop and continue the animation while it plays.

  1. Reopen Scene 1 the wine_expert Movie Clip.
  2. Insert a new layer for the buttons. You don't want to place buttons in the layer with an animation; that will affect the tween. Name this layer Buttons.
  3. Into the Buttons layer, draw an Oval that will become your button.
  4. Screen shot of workspace. Select it, and then convert to symbol (F8). Name it MyButton and make sure the behavior is set to Button.
  5. You'll need two buttons, so either copy and paste the instance already onstage or drag another instance of the MyButton symbol from the Library onto the Stage in the Buttons layer.
  6. Apply a Tint color style to each instance—one red (for Stop) and one green (for Play). You can do all this from the Properties panel.
  7. Using the Text tool type STOP on the Red button and PLAY on the Green button. Use Arial Black at 20pt and a Black color.
  8. You need to attach an Action to each button individually. Select the red button and access the Actions panel [F9]. From the plus button select Global Functions > Movie Clip Control > on choose release and then, select Global Functions > Timeline Control > Stop.
  9. On release choices in ActionScriptPath to Actions needed.

  10. Now select the green Play Button instance and assign the Play Action select, Global Functions > Movie Clip Control > on choose release and then, select Global Functions > Timeline Control > Play.

What you’ve learned in this lesson:

  • Putting Actions in keyframes causes the Action to execute when that frame is reached.
  • Putting Actions on instances of buttons makes the Action execute when the user clicks a button.
  • Keyframe Actions are fairly straightforward: You assign them to the keyframe. Buttons on the other hand, require that you specify to which mouse event you want to respond, mouse press, mouse release, etc.

NEW TERM: Mouse Events are specific situations that refer to exactly how the user is interacting with a button.

 

Back to Top