Click to Show Lecture Notes

Flash MX Button Actions...

Putting Actions in keyframes causes the Action to execute when that frame is reached, putting Actions on instance 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.

This page will add some buttons to the Welcome animation you recently made when you first entered this section.

Add Buttons To An Animation Add Buttons To An Animation

Add Buttons To An Animation

Re-open the Welcome animation so we can let the user stop and continue the animation while it plays.

  1. 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.


  2. Into the Buttons layer, draw a rectangle that will become your button. Select it, and then convert to symbol (F8). Name it MyButton and make sure the behavior is set to Button.


  3. 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.


  4. 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.

  5. Adding Buttons to the Stage.

    Adding the Buttons to the Stage

    Hide the Image

  6. You need to attach an Action to each button individually. Select the red button and access the Actions panel. From the plus button select Actions >Movie Control > Stop to add an Action statement to the Script Area on the Right. The default event is Release, meaning the Action will execute when the user clicks then release the button.


  7. Now select the green Button instance and assign the Play Action, found under Actions > Movie Control > Play. Test the movie, did it work?


  8. Hide Practice Session 1

Now that you've had a chance to try this on your own, check the Flash Movie I made (click the glasses icon). Does yours act the same way as mine? If you have the time, you should try to make a couple of more interesting looking buttons than the ones I did for the exercise.

View the Flash Movie from this Session.

Hide the Movie
Page Updated on March 2, 2003