I have a Flash file that has two music tracks. The player I built works well so far except for this, I am trying to make a Pause/Play button the works on either track. Right now it only works on one. With my limited knowledge of AS3 I tried different solutions but none worked.
Here is the SWF file; http://www.garrigan.net/Question/
You will see that the Pause/Play button only works on “Kiss My Dogg” which is track 1.
Here is the FLA file; http://www.garrigan.net/Question/fla/
Below is some of the Script I wrote. The pause/play is the part I can’t figure out. Does anyone have a solution? I am stump.
Thanks in advance for any input anyone may have.
//function to load different tracks
function loadMusic(evt:MouseEvent):void{
//stop whatever is playing
SoundMixer.stopAll();
switch(evt.target.name){
case “track1_btn”:
channel=snd1.play();
display_txt.text=“Now playing Kiss My Dogg”;
break;
case “track2_btn”:
channel=snd2.play();
display_txt.text=“Now playing Watch Dog”;
break;
}
}
//function to create pause/play
function myPause(evt:MouseEvent):void{
var pausePos:Number=channel.position;
if(musicPlaying){
channel.stop();
musicPlaying=false;
}else{
channel=snd1.play(pausePos);
musicPlaying=true;
}
}
//function to stop music tracks
function myStop(evt:MouseEvent):void{
SoundMixer.stopAll();
display_txt.text=“Music Stopped”;
}
stage.addEventListener(Event.ENTER_FRAME,mySettings);
vDrag_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragVol);
vDrag_mc.addEventListener(MouseEvent.MOUSE_UP,dragStop);
vDrag_mc.addEventListener(MouseEvent.MOUSE_OUT,dragStop);
track1_btn.addEventListener(MouseEvent.CLICK,loadMusic);
track2_btn.addEventListener(MouseEvent.CLICK,loadMusic);
playPause_btn.addEventListener(MouseEvent.CLICK,myPause);
stop_btn.addEventListener(MouseEvent.CLICK,myStop);