Friday 21 December 2012

play sound using button in action script 3.0





var my_sound:SoundId = new SoundId();
var my_channel:SoundChannel = new SoundChannel();


play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);


function playSound(event:MouseEvent):void{
my_channel = my_sound.play();
}


function stopSound(event:MouseEvent):void{
my_channel.stop();
}


1. Create play button instance of 'play_btn'.
2. Create stop button instance of 'stop_btn'.


No comments:

Post a Comment