1

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.

cholverson
  • 61
  • 1
  • 7

1 Answers1

1
  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();
});
mihai
  • 4,184
  • 3
  • 26
  • 27
  • Awesome, I think we're heading in the right direction. A few questions though: As far as the movieclip you are referencing in your example code, I don't have a movie clip. I just have a layer with images, there isn't really a "movie". So the audio is playing, meanwhile the image displays, if the audio begings to talk about something new, the image changes. So the myTimeline reference is confusing me, what should I use instead? – cholverson Jan 31 '14 at 20:44
  • if the AS3 is in the same timeline with the animation (in the same movieclip) then set var myTimeline:MovieClip = this; since this is your timeline. – mihai Feb 02 '14 at 00:37
  • It's not. I have a "Shared Actions" layer with everything defined, then only AS3 on the button layers. So for example I have a Next button with this code: Next1.addEventListener(MouseEvent.CLICK,Nclick1); A Back button with this code: Back1.addEventListener(MouseEvent.CLICK,Bclick1); And then on the Shared Actions layer I have: //stop play on the first frame stop(); function Nclick1(event:MouseEvent):void { SoundMixer.stopAll(); gotoAndPlay(25); } function Bclick1(event:MouseEvent):void { SoundMixer.stopAll(); gotoAndPlay(2); } – cholverson Feb 03 '14 at 16:49
  • Sorry, I can't figure out how to make the code look nice in these comments! – cholverson Feb 03 '14 at 16:56
  • Maybe it will help if you think of it not like a movie clip, but more like this deal is a slideshow with narration. I am trying to build another one from scratch but the whole defining the myTimeline thing is still throwing me off. – cholverson Feb 04 '14 at 18:27
  • @cholverson it would be easier if you posted an image here (maybe imgur hosted) so I can see what your flash IDE timeline looks like. – mihai Feb 04 '14 at 19:18