Play/Pause streaming audio button for each frame
I have streaming audio on each frame that automatically starts and stops when the next or previous frame is clicked. I need to add a pause button on each frame. I have created a play/pause toggle movie clip on my first frame and it works fine. Frame one uses mySound1 and myChannel1, frame two uses mySound2 and myChannel2, etc.
When I try to add the code to the next frame I get errors. What do I need to do to have a button on each frame to stop the corresponding mp3? I appreciate your help!
SoundMixer.stopAll();
var pP:Number = 0;//playback position
var playing:Boolean = false;
var mySound1:Sound = new Sound();
var myChannel1:SoundChannel = new SoundChannel();
mySound1.load(new URLRequest("Physiology Slide 01 INTRO.mp3"));
myChannel1 = mySound1.play();
SoundMixer.stopAll();
PlayPause_btn.addEventListener(MouseEvent.CLICK, togglePlay);
togglePlay(null);
function togglePlay(event:MouseEvent):void {
playing = !playing;
if (playing) playS();
else pauseS();
}
function playS() {
myChannel1 = mySound1.play(pP);
PlayPause_btn.gotoAndStop(2);
}
function pauseS() {
pP = myChannel1.position;
myChannel1.stop();
PlayPause_btn.gotoAndStop(1);
}
