0
votes

Now I'm having problems with my flash game especially going to level two. The problem started when I added the container for the locked door and the key. The game was in working condition like the sprites work, getting the key in level one works and unlocking it works. Trying for Level 2 becomes a pain. Help me please.

TypeError: Error #2007: Parameter hitTestObject must be non-null.

at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at TheHunterWithinv0_Scene1_fla::MainTimeline/loop()
1
if(keyCollected == false){ if(player.hitTestObject(back.doorKey)){ back.doorKey.visible = false; keyCollected = true; } } if(doorOpen == false){ if(keyCollected == true){ if(player.hitTestObject(back.lockedDoor)){ back.lockedDoor.gotoAndStop(2); doorOpen = true; } } }user3400004
function nextLevel():void { currentLevel++; trace("Next Level: " + currentLevel); if(currentLevel == 2){ gotoLevel2(); } } function gotoLevel2():void { back.other.gotoAndStop(2); back.visuals.gotoAndStop(2); back.collisions.gotoAndStop(2); scrollX = 0; scrollY = 500; keyCollected = false; back.other.doorKey2.visible = true; doorOpen = false; back.other.lockedDoor2.gotoAndStop(1); } function keyDownHandler(e:KeyboardEvent):void { } else if(e.keyCode == Keyboard.DOWN){ downPressed = true; if(doorOpen && player.hitTestObject(back.other.lockedDoor)){ nextLevel(); } } }user3400004
You should edit your question to include the code that you've added as comments.Don Cruickshank

1 Answers

2
votes

Error comes when object is removed from the stage, You should check the reference of object you are passing in hittestobject.