How to Code for a Replay Button in Flash

Written by willa dunn
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Code for a Replay Button in Flash
Make your animation more interactive with a replay button. (Comstock Images/Comstock/Getty Images)

The Adobe Flash interface includes a timeline that helps you control your animation flow from start to finish. The default behaviour is for the animation to loop, or begin at the start again after it has reached the last frame in the timeline. Adding a replay button for this action may be more feasible for your movie. Create a button and use ActionScript to write the button code that enables user interaction and control over how your movie plays.

Skill level:
Moderately Easy

Other People Are Reading

Instructions

  1. 1

    Launch Flash and select the "File" menu, and then "Open." Choose your Flash file and click "Open."

  2. 2

    Click the Text tool in the Tools panel and type "Restart." Press "F8" and choose "Button." Click "OK."

  3. 3

    Type "restartBtn" for the Properties panel Instance Name. Open the Actions panel by pressing "F9."

  4. 4

    Type the ActionScript button actions:

    restartBtn.addEventListener(MouseEvent.MOUSE_DOWN, down Event);

    function down Event(e:MouseEvent):void{

    gotoAndPlay(1);
    

    }

    The gotoAndPlay value of "1" refers to the first frame in the timeline. The animation restarts at frame one when the button is clicked.

  5. 5

    Press "Ctrl" and "Enter" to test your button.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.