# How do I make a Pause/Play function for multiple audio tracks?

**URL:** <https://forum.kirupa.com/t/how-do-i-make-a-pause-play-function-for-multiple-audio-tracks/294415>\
**Category:** flash\
**Created:** [August 13, 2009, 5:05pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-pause-play-function-for-multiple-audio-tracks/294415 "2009-08-13T17:05:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kodos](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kodos](https://forum.kirupa.com/u/kodos)\
**Post date:** [August 13, 2009, 5:05pm UTC](https://forum.kirupa.com/t/how-do-i-make-a-pause-play-function-for-multiple-audio-tracks/294415/1 "2009-08-13T17:05:24Z")

</div>

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/](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/](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);
