Start and Stop sound with buttons.
Using URLRequest and events
var req:URLRequest=new URLRequest("sound.mp3");
var mySound:Sound=new Sound ;
var myController:SoundChannel;
mySound.load(req);
mySound.addEventListener(Event.COMPLETE, mySoundLoaded);
function mySoundLoaded(event:Event):void {
play_btn.addEventListener(MouseEvent.CLICK, playMySound);
stop_btn.addEventListener(MouseEvent.CLICK, stopMySound);
}
function playMySound(event:MouseEvent):void {
myController=mySound.play();
}
function stopMySound(event:MouseEvent):void {
myController.stop();
}
Thank you for reading.
Sours you can find in attached file.
+