Skip to main content
Participating Frequently
October 21, 2013
Answered

Stop all sounds as3? Help

  • October 21, 2013
  • 1 reply
  • 2570 views

When the game starts. I have toggle button. I can play a sound or stop sound. When i play the sound, of course its not muted so even if i go to the next page. I can reason out that the sounds will still play.

But if i press the no sound,so it means it must be muted.. on the first screen, the sound stops. But when I go the next frames and to others. The sounds are playing. The sound on the starting screen

was like

var test:Sound = new NameOfSound();

but in the next frames.. the sound is in the frame itself.. no declaring like the first screen..

and also some sounds is playing when something happens or for example if the bullet hits the target collsion..sound play..

i tried to have solution like on the first screen if for example it is muted.. ill set it to trueStop.. then on the next frames.. i would put:

if(trueStop == true){

     SoundMixer.stopAll();

}

that way the frame sounds stopped and working.. but the sounds attach to the function when like i said if a collision happens,, the sound is still playing.. arrgghh i cant explain clearly.. i hope you understand my problem..

any ideas?

This topic has been closed for replies.
Correct answer kglad

if you need to stop individual sounds, assign a soundchannel to the instance returned by your play method and apply a stop method to that soundchannel.

for example:

var s1:Sound=new S1();

var sc1:SoundChannel=s1.play();

// now at any time you can use:

sc1.stop();  // to stop s1 only.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 21, 2013

if you need to stop individual sounds, assign a soundchannel to the instance returned by your play method and apply a stop method to that soundchannel.

for example:

var s1:Sound=new S1();

var sc1:SoundChannel=s1.play();

// now at any time you can use:

sc1.stop();  // to stop s1 only.

Participating Frequently
October 21, 2013

i have 10 sounds .. do i have to make 10 of sound channels? cause im just using the sound channel on the starting screen..

kglad
Community Expert
Community Expert
October 21, 2013

yes.

if you want to control each sound independently of the others, create an unique soundchannel instance for each: