Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
}
Copy link to clipboard
Copied
Thanks for the attention but it did not work. Thank you very much.
I'll look for another solution.
Because the audio starts at one frame, and I stop it at another. But the audio does not stop, it resumes over the previous one, the stop function is not working with the "(0, 999") loop.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now