Using: Flash CS3 and Actionscript 2
I want to have background sound on and toggle on or off background music. E.g. I have rain playing in the background but also want to toggle music on or off without affecting the background sounds.
I can toggle sound with a button but it stops all sound, and when I press play only the music plays without the rain.
This is the code I used:
var mysound:Sound = new Sound();
var pause_spot:Number = new Number();
pause_spot = 0
mysound.attachSound("music")
mysound.start(pause_spot,99);
Pause_BTN._visible = true;
Play_BTN._visible = false;
Pause_BTN.onRelease = function(){
pause_spot = (mysound.position/1000);
mysound.stop();
Pause_BTN._visible = false;
Play_BTN._visible = true;
}
Play_BTN.onRelease = function(){
mysound.start(pause_spot,99);
Pause_BTN._visible = true;
Play_BTN._visible = false;
}