Need to create a pause/resume toggle button in Flash CS3 AS3

2.6k views Asked by At

OK, I have seen a lot of questions and answers on how to code pause/resume buttons, but none of them fit my specific need. First let me explain what I have:

I have made a tutorial video for my job. It consists of screens shots and sounds. I have a forward button that skips to the next section (usually the start of the next audio file) and a back button that goes to the previous section. However I need a pause button.

Now let me explain how I have built it:

I have made the movie at 1fps. I have a layer for Audio, a layer for the screen shots, a layer for each button, and various other layers for highlighting things in the screen shots. On the Audio layer I placed my audio file on the stage and then dragged out the number of frames until the entire audio file could play uninterrupted. So if the audio was 10 seconds long, it lives across 10 frames. I can then put my screenshot on its own layer and do the same so that the image displays the same length of time as the audio. When the frame ends, it automatically skips to the next frame and continues on until the end. Since the audio is on the stage, the viewer doesn't need to do anything to get the audio to play.

After viewing many tutorials, it seems like most people use code to get the audio to play rather than putting it on the stage. I am not this skilled.

So my question is, with my current set up, how can I make a toggle button that basically says "If audio is playing, stop the whole show when clicked- if audio is not playing, resume show from last position when clicked"?

Thank you so much if you can help! Also, this is my first time asking a technical question like this, please let me know if you need any other specific details.

1

There are 1 answers

6
mihai On
  1. First make sure all audios on your timeline are set to "Stream". To do this click on the frame where your audio lies, find the sound panel, change it from Event to Stream. this will ensure that when the timeline is stopped the audio stops and resumes when the timeline is played.
  2. As for the buttons simply make one that calls stop() on the timeline and one that calls play(). This will stop the timeline wherever it is and resume it on play.
var myTimeline:MovieClip;//link to the movieclip where your timeline animation lies
var btnPause:SimpleButton;//link to your pause button
btnPause.addEventListener(MouseEvent.CLICK,function(event:MouseEvent):void{
    myTimeline.stop();
});
var btnResume:SimpleButton;//link to your resume button
btnResume.addEventListener(MouseEvent.CLICK,function(event:MouseEvent):void{
    myTimeline.play();
});