I really need help, I've been stuck on this problem for the pass 2 days. I keep getting this error when navigating back to another frame!
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at product_fla::MainTimeline/frog_mcRelease()
the frog_mc keeps going onto another frame!! don't know whats wrong.
thanks
my code:
import flash.events.Event;
right_mc.visible=false;
wrong_mc.visible=false;
var orig1X:Number=frog_mc.x;
var orig1Y:Number=frog_mc.y;
var orig2X:Number=queen_mc.x;
var orig2Y:Number=queen_mc.y;
var orig3X:Number=apple_mc.x;
var orig3Y:Number=apple_mc.y;
stage.removeEventListener(Event.ENTER_FRAME, frog_mcRelease);
frog_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
frog_mc.addEventListener(MouseEvent.MOUSE_UP, frog_mcRelease);
queen_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
queen_mc.addEventListener(MouseEvent.MOUSE_UP, queen_mcRelease);
apple_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragTheObject);
apple_mc.addEventListener(MouseEvent.MOUSE_UP, apple_mcRelease);
done_btn.addEventListener(MouseEvent.CLICK, checkAnswers);
reset_btn.addEventListener(MouseEvent.CLICK, reset);
frog_mc.buttonMode=true;
queen_mc.buttonMode=true;
apple_mc.buttonMode=true;
function dragTheObject(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.startDrag();
var topPos:uint=this.numChildren-1;
this.setChildIndex(item, topPos);
}
function frog_mcRelease(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (drop_frog.hitTestPoint(item.x,item.y)) {
item.x=drop_frog.x;
item.y=drop_frog.y;
} else {
item.x=orig1X;
item.y=orig1Y;
}
};
function queen_mcRelease(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (drop_queen.hitTestPoint(item.x,item.y)) {
item.x=drop_queen.x;
item.y=drop_queen.y;
} else {
item.x=orig2X;
item.y=orig2Y;
}
};
function apple_mcRelease(event:MouseEvent):void {
var item:MovieClip=MovieClip(event.target);
item.stopDrag();
if (drop_apple.hitTestPoint(item.x,item.y)) {
item.x=drop_apple.x;
item.y=drop_apple.y;
} else {
item.x=orig3X;
item.y=orig3Y;
}
};
function checkAnswers(event:MouseEvent):void {
if (drop_frog.hitTestPoint(frog_mc.x,frog_mc.y) &&
drop_queen.hitTestPoint(queen_mc.x,queen_mc.y) &&
drop_apple.hitTestPoint(apple_mc.x,apple_mc.y)) {
wrong_mc.visible = false;
right_mc.visible = true;
} else {
wrong_mc.visible = true;
right_mc.visible = false;
}
}
function reset(event:MouseEvent):void {
frog_mc.x=orig1X;
frog_mc.y=orig1Y;
queen_mc.x=orig2X;
queen_mc.y=orig2Y;
apple_mc.x=orig3X;
apple_mc.y=orig3Y;
right_mc.visible=false;
wrong_mc.visible=false;
}