MAIN CODE
stop();
//import flash.events.MouseEvent;
//RATTLE
function onOver(e:MouseEvent):void {
rattleBtn.setImage("OVER");
}
function onDown(e:MouseEvent):void {
rattleBtn.setImage("DOWN");
}
function onOff(e:MouseEvent):void {
rattleBtn.setImage("OFF");
}
function rPlay(e:MouseEvent):void {
gotoAndPlay("rattle");
}
rattleBtn.addEventListener(MouseEvent.ROLL_OVER, onOver);
rattleBtn.addEventListener(MouseEvent.MOUSE_OUT, onOff);
rattleBtn.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
rattleBtn.addEventListener(MouseEvent.MOUSE_UP, rPlay);
//PACIFIER
function ponOff(e:MouseEvent):void
{
pacBtn.setPImage("POFF");
}
function ponOver(e:MouseEvent):void {
pacBtn.setPImage("POVER");
}
function ponDown(e:MouseEvent):void {
pacBtn.setPImage("PDOWN");
}
function toPlay(e:MouseEvent):void {
gotoAndPlay("pacifier");
}
pacBtn.addEventListener(MouseEvent.MOUSE_OUT, ponOff);
pacBtn.addEventListener(MouseEvent.ROLL_OVER, ponOver);
pacBtn.addEventListener(MouseEvent.MOUSE_DOWN, ponDown);
pacBtn.addEventListener(MouseEvent.MOUSE_UP, toPlay);
//BOTTLE
function bonOff(e:MouseEvent):void {
botBtn.setBImage("BOFF");
}
//botBtn.addEventListener(MouseEvent.MOUSE_OUT, bonOff);
function bonOver(e:MouseEvent):void {
botBtn.setBImage("BOVER");
}
function bonDown(e:MouseEvent):void {
botBtn.setBImage("BDOWN");
}
function bonUp(e:MouseEvent):void {
//botBtn.setBImage("BOFF");
gotoAndPlay("bottle");
}
botBtn.addEventListener(MouseEvent.MOUSE_OUT, bonOff);
botBtn.addEventListener(MouseEvent.ROLL_OVER, bonOver);
botBtn.addEventListener(MouseEvent.MOUSE_DOWN, bonDown);
botBtn.addEventListener(MouseEvent.MOUSE_UP, bonUp);
BUTTON CODE ex for Rattle
function setImage(which:String):void {
switch (which) {
case "OFF" :
gotoAndStop("off");
break;
case "OVER" :
gotoAndPlay("over");
break;
case "DOWN" :
gotoAndStop("down");
break;
}
}
ERRORS
I got after adding a MOUSE_OUT event for every button. Errors show up after button is clicked but the movie still works.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/ponOff()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/onOff()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/bonOff()