spark067
09-10-2008, 05:37 PM
Hello everyone,
I have a question that I have three sound buttons click to hear a sound. It works only one button with below the code. How to make to work with three sound buttons? Looks like simple but I can't figure it out. Am I using a wrong code here? Please help me.
var loadSnd:URLRequest = new URLRequest("SORTER.mp3");
var thisSnd:Sound = new Sound();
var sndTrans:SoundChannel = new SoundChannel();
thisSnd.load(loadSnd);
play_btn.addEventListener(MouseEvent.CLICK, playF);
stop_btn.visible = false;
stop_btn.addEventListener(MouseEvent.CLICK, stopF);
function playF(event:MouseEvent):void{
SoundMixer.stopAll();
sndTrans = thisSnd.play();
play_btn.visible = false;
stop_btn.visible = true;
}
function stopF(event:MouseEvent):void{
sndTrans.stop();
stop_btn.visible = false;
play_btn.visible = true;
}
Any help would be greatly appreciated.
Thanks,
I have a question that I have three sound buttons click to hear a sound. It works only one button with below the code. How to make to work with three sound buttons? Looks like simple but I can't figure it out. Am I using a wrong code here? Please help me.
var loadSnd:URLRequest = new URLRequest("SORTER.mp3");
var thisSnd:Sound = new Sound();
var sndTrans:SoundChannel = new SoundChannel();
thisSnd.load(loadSnd);
play_btn.addEventListener(MouseEvent.CLICK, playF);
stop_btn.visible = false;
stop_btn.addEventListener(MouseEvent.CLICK, stopF);
function playF(event:MouseEvent):void{
SoundMixer.stopAll();
sndTrans = thisSnd.play();
play_btn.visible = false;
stop_btn.visible = true;
}
function stopF(event:MouseEvent):void{
sndTrans.stop();
stop_btn.visible = false;
play_btn.visible = true;
}
Any help would be greatly appreciated.
Thanks,