Question
AS3 stopping audio streaming inside a layer
Sometimes I get ahead of myself and have to stop and say how the hell did I do this before? I'm referring to a simple stop button I need to put in a flash animation. I know how to code calling a sound from the library, starting and stopping. But how do I stop audio that is streaming inside a layer from a button ?
var my_sound:Sound = new Sound();
my_sound.load(new URLRequest("yoursoundfile.mp3"));
var my_channel:SoundChannel = new SoundChannel();
//2.
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
//3.
function playSound(event:MouseEvent):void{
my_channel = my_sound.play();
}
//4.
function stopSound(event:MouseEvent):void{
my_channel.stop();
}