00:00
00:00
Newgrounds Background Image Theme

Breakfast-Crow just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Stop/Start 1 Sound With Button

1,001 Views | 2 Replies
New Topic Respond to this Topic

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;
}

Stop/Start 1 Sound With Button

Response to Stop/Start 1 Sound With Button 2016-04-19 18:20:53


Your start button is only starting the music, according to that code. As for why the rain sound effect is also stopping when only the music should, I can't say; there's nothing in that code snippet relating to the rain sound.

Can you post the code that deals with starting the rain sound?

Response to Stop/Start 1 Sound With Button 2016-04-19 18:23:28


Can you post the code that deals with starting the rain sound?

The rain is on a layer of its own, there is no code.