Skip to main content
Known Participant
June 7, 2013
Answered

Creating Replay Button

  • June 7, 2013
  • 1 reply
  • 2229 views

I have three flv components on stage that all play simultaneously. I would like to insert a replay button that appears at the end of the clip.

What code must I insert and which layer do I put it on. Note I have three layers each with a flv component. My second question is what is the process to creating a custom replay button? I already have the image I want to use.

This topic has been closed for replies.
Correct answer Ned Murphy

To create the button, just take the image you have, place it on the stage, and choose Modify -> Create Symbol and turn it into a MovieClip symbol.

To code the button you need to assign an event listener for a CLICK event.  So assign an instance name to the button and in a layer dedicated to Actionsacript add an event listener to it.

yourBtnName.addEventListener(MouseEvent.CLICK, replayMovies);

function replayMovies(evt:MouseEvent):void {

      // look in the Flash help documentation for the code you need

      //  to use to reset and replay the FLVPLayback component)(s)

}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
June 7, 2013

To create the button, just take the image you have, place it on the stage, and choose Modify -> Create Symbol and turn it into a MovieClip symbol.

To code the button you need to assign an event listener for a CLICK event.  So assign an instance name to the button and in a layer dedicated to Actionsacript add an event listener to it.

yourBtnName.addEventListener(MouseEvent.CLICK, replayMovies);

function replayMovies(evt:MouseEvent):void {

      // look in the Flash help documentation for the code you need

      //  to use to reset and replay the FLVPLayback component)(s)

}

Known Participant
June 7, 2013

I created the symbol and turned it into a Movieclip symbol and created a layer dedicated to Actionscript. I then added the following code:

yourBtnName.addEventListener(MouseEvent.CLICK, replayMovies);

function replayMovies(evt:MouseEvent):void {

When I test the scene the replay button appears throughout the whole clip, how do I get the replay button to only appear once the clip is finished playing?

Ned Murphy
Legend
June 7, 2013

First you need to set the visible property of the button to false.

     yourBtnName.visible = false;

Then assign an event listener to your FLVPlayback for its COMPLETE event and use that to trigger setting the visible property of the button to true.

     import fl.video.VideoEvent;

     yourFLVPlaybackName.addEventListener(VideoEvent.COMPLETE, showButton);

     function showButton(evt:VideoEvent):void {

            yourBtnName.visible = true;

     }

and change your replayMovies function to include that same line that makes the button invisible again.

By the way, I did not literally mean for you to name the button yourBtnName.  You can name it anything you please.