Button Action Scripts

 
In this activity you will create buttons that control a movie clip.
 
  1. Open the Action_Script1 flash file that you created in the previous lesson. If the previous file is not available create a simple motion tween with at least 30 frames.
  2. Create a new layer called Buttons and then draw a rectangle. Convert the rectangle into a button symbol called MyButton.
  3. Drag another copy of MyButton onto the stage, you will need one to stop the movie and one to play the movie. Change the color of one button to red for stop and the other one to green.
  4. Give the green button the instance name "green" and the red button an instance name of "red".
  5. Select the red button and access the actions panel. The tab should say "red" and the button icon should appear. Click the + button and select Global Functions > Timeline > Control > Stop.
  6. Button actions always take place because of an EVENT so we need to add two lines of code to the stop( ): script. Add the following line before the stop line: on(press) { then place a } on the line after stop. Your script should look like this:
    on(press) {
    stop( );
    }
  7. Use this same procedure to make the Go button.
  8. Demonstrate the movie to your instructor for teacher check.