I have three buttons. My goal is that each button will load and play a sound file from the internet. Here is what I have:
function loadPlaySnd(pSpecifier1:String):void {
arguments;
SoundMixer.stopAll();
var sndRequest:URLRequest = new URLRequest ();
sndRequest = new URLRequest ("http://www.geocities.com/stinkmoe/"+pSpecifier1+".mp3");
var snd:Sound = new Sound ();
snd.load(sndRequest);
snd.addEventListener(Event.COMPLETE, loadingCompleteHandler);
function loadingCompleteHandler(e:Event):void {
trace ("Sound has loaded");
snd.play();
}
}
basketball_btn.addEventListener(MouseEvent.CLICK, function () {loadPlaySnd(“basketball”);});
whistle_btn.addEventListener(MouseEvent.CLICK, function () {loadPlaySnd(“whistle”);});
scoreboard_btn.addEventListener(MouseEvent.CLICK, function () {loadPlaySnd(“scoreboard”);});
My problem is this:
Every Button I press goes to the same sound file. The best I can figure, is that the file I loaded the first time I pressed a button has been uploaded, and from there I cannot load another file over that variable when I try another button. Anything blatantly wrong with what I’m doing? Do I need to clairify anything here?
Do I need to clear my variables somehow when the sound finishes playing?