Hi, I am having some trouble performing a hit test in a frog game I am making.
When the UP key on the keyboard is pressed an animation in my ‘frog’ MovieClip plays of a frog jumping, and at frame 22 and 23 (the peak of it’s jump) a second nested MovieClip appears for those 2 frames with instance name ‘mouth’.
I am trying to hit test mouth against ‘fly’ which is found on the main timeline.
Here is the code which I can’t figure out:
stage.addEventListener(KeyboardEvent.KEY_DOWN, frogJump);function frogJump(event:KeyboardEvent)
{
if(event.keyCode==38)
{
frog.gotoAndPlay(2);
if ((Object(this).frog.mouth).hitTestObject(fly)) {trace("FLY HIT")}
}
}
I receive the following error when UP is pressed:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FrogGame_Game_fla::MainTimeline/frogJump()
Thanks for the help.