Ok I have tried searching around for adding a beep to my buttons in AS3 I can’t seem to find anything that makes sense for my arrays. I need it to make the sound on click so I am pretty sure I need it to go under “doClick4”.
This is the sound code I was trying in the array:
It just makes my whole site start over.
var soundReq: URLRequest = new URLRequest ("lock-beep.wav");
var sound: Sound = new Sound ();
var soundControl:SoundChannel = new SoundChannel();
sound.load(soundReq);
sound.addEventListener (Event.COMPLETE, onComplete);
function onComplete (event: Event): void
{
soundControl = sound.play();
}
This is my array for my buttons:
var buttonsArray4:Array = [btn_lock1, btn_lock2, btn_lock3, btn_lock4, btn_lock5, btn_lock6, btn_lock7, btn_lock8, btn_lock9, btn_lock0, btn_lock10, btn_lock11];
function setButtons4():void {
for (var i:int=0; i<buttonsArray4.length; i++) {
buttonsArray4*.id = i;
buttonsArray4*.buttonMode = true;
buttonsArray4*.mouseChildren = false;
buttonsArray4*.mouseEnabled = true;
buttonsArray4*.addEventListener(MouseEvent.ROLL_OVER,playOver4);
buttonsArray4*.addEventListener(MouseEvent.ROLL_OUT,playOut4);
buttonsArray4*.addEventListener(MouseEvent.CLICK,doClick4);
}
}
function playOver4(event:MouseEvent):void {
event.currentTarget.gotoAndPlay("over");
}
function playOut4(event:MouseEvent):void {
event.currentTarget.gotoAndPlay("out");
}
function doClick4(event:MouseEvent):void{
var currentBtn4:int = event.currentTarget.id;
setSelectedBtn4(currentBtn4);
}
function setSelectedBtn4(id:int):void{
for (var i:int=0; i< buttonsArray4.length; i++) {
if (id == i) {
buttonsArray4*.gotoAndPlay("down");
buttonsArray4*.buttonMode = false;
buttonsArray4*.mouseEnabled = false;
buttonsArray4*.removeEventListener(MouseEvent.ROLL_OVER,playOver);
buttonsArray4*.removeEventListener(MouseEvent.ROLL_OUT,playOut);
buttonsArray4*.removeEventListener(MouseEvent.CLICK,doClick4);
} else {
if(buttonsArray4*.currentLabel =="down"){
buttonsArray4*.gotoAndPlay("out");
}
buttonsArray4*.buttonMode = true;
buttonsArray4*.mouseEnabled = true;
buttonsArray4*.addEventListener(MouseEvent.ROLL_OVER,playOver);
buttonsArray4*.addEventListener(MouseEvent.ROLL_OUT,playOut);
buttonsArray4*.addEventListener(MouseEvent.CLICK,doClick4);
}
}
}
setButtons4();