The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: hitTestObject from within an animated MovieClip help!

  1. #1
    Registered User

    hitTestObject from within an animated MovieClip help!

    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 ((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.
    Last edited by 49th; May 1st, 2012 at 07:34 PM.

  2. #2
    Registered User
    Turns out I have solved the problem after over an hour of trying different stuff:
    I put the hit test code within the actual movieclip and now it is working.
    That feeling when you work something out is great. Even though it was probably the simplest thing!

  3. #3
    That's not really a solution Especially if your whole project's As is on the first layer. I think it has to do with the this in your hitTest.
    As3 / JS/jQuery / HTML5 / CSS(3) / PHP (intermediate)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012