Skip to main content
Inspiring
December 22, 2016
Question

Stop loop Sound

  • December 22, 2016
  • 1 reply
  • 480 views

Hello users, I'm going through a difficult time trying to stop a loop from an audio, even using the class + stop, the same does not stop.

I've been trying to focus on this for a few hours, and all the attempts have been in vain:

var mySound:ambientSound = new ambientSound();

function good (Event:MouseEvent) : void {

     MySound.play(0, 999); // Loop

}

function bad (Event:MouseEvent) : void {

     MySound.stop();

}

Could someone clarify to me why this occurs, and a solution? Grateful!

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
December 22, 2016

I am not familiar with the ambientSound class, but you should be using the same variables... case matters...  mySound  is not the same as MySound

vvvverTAuthor
Inspiring
December 22, 2016

It was a small mistake at the time of publication. It's mySound, correct.

But the sound does not stop, I already tried mySound.stop ();

MySound.stopAll (); ... Nothing comes up to stop the sound.

Ned Murphy
Legend
December 23, 2016

Check out the ambientSound class help files if you can find them.  It should explain how to use the class to control sound if it has that ability.

As I said, I am not familiar with that class.  In AS3 in the days when I used it, there were two elements to sound... the Sound and the SoundChannel classes.  If you wanted to stop a sound you did it thru the SoundChannel...

var aSound:Sound = new MySound();

var aChannel:SoundChannel = new SoundChannel();

aChannel.addEventListener(Event.SOUND_COMPLETE, playAgain);

aChannel=aSound.play();    //assign the sound channel to the sound when you make it play

function stopSound(event:MouseEvent):void { // this example used a mouseclick to toggle the sound off

            aChannel.stop();    // you stop the channel

}