Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Error #2007 - hitTestObject must be non-null

New Here ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

Ok, so I'm making a game in flash CS3 and I want the character to be able to move to other rooms when they hit something like a door. The way I'm doing it is actionscript goes to another frame when the player movie clip, gpb, hits the door. But it keeps coming up with an error that says "TypeError: Error #2007: Parameter hitTestObject must be non-null." I have no idea what's wrong with it.
Here's the code for what I'm trying to do:

gpb.addEventListener(Event.ENTER_FRAME, collide)

function collide(e:Event){
if(gpb.hitTestObject(door)){
gpb.x=600
gotoAndPlay(3);
}

}
TOPICS
ActionScript

Views

5.6K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

flash doesn't see a display object with instance name door. door is likely to be an object that existed at one time (or you'd get an 1120 error), but has been gc'd.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 21, 2008 Mar 21, 2008

Copy link to clipboard

Copied

Thanks for the reply. I think I got it working now.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 22, 2008 Mar 22, 2008

Copy link to clipboard

Copied

you're welcome. what was the problem cause?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 22, 2008 Mar 22, 2008

Copy link to clipboard

Copied

I didn't have the door on the next frame and flash couldn't find the door on that frame. So I put in another layer and put the door object on that and that seems to have done the trick.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 22, 2008 Mar 22, 2008

Copy link to clipboard

Copied

LATEST
thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines