Skip to main content
Known Participant
February 2, 2022
Answered

Error 2007

  • February 2, 2022
  • 1 reply
  • 849 views

Hello, I am creating a game in action script 3.0

My code is the the following:

 

stop( );

{
trap.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
trap.addEventListener(MouseEvent.MOUSE_UP, dropIt);
trap.startX = trap.x;
trap.startY = trap.y;

}

function pickUp(event:MouseEvent):void
{

event.target.startDrag(true);
event.target.parent.addChild(event.target);

}
function dropIt(event:MouseEvent):void
{

event.target.stopDrag();
if(event.target.hitTestObject(target1)){
MovieClip(this.root).gotoAndPlay(1,"xana1");
if (MovieClip(this.root)) gotoAndPlay(1,"xana1") ;{
removeChild(trap); }

}
else
{

event.target.x = event.target.startX;
event.target.y = event.target.startY;
event.target.buttonMode = true;

}
}

{

psar.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
psar.addEventListener(MouseEvent.MOUSE_UP, dropIt);
psar.startX = psar.x;
psar.startY = psar.y;
}
function PickUp(event:MouseEvent):void
{

event.target.startDrag(true);
event.target.parent.addChild(event.target);

}
function dRopIt(event:MouseEvent):void
{

event.target.stopDrag();
if(event.target.hitTestObject(target1)){
MovieClip(this.root).gotoAndPlay(1, "bravo1");
if (MovieClip(this.root))gotoAndPlay(1, "bravo1") ;{
removeChild(psar); }

}
else
{

event.target.x = event.target.startX;
event.target.y = event.target.startY;
event.target.buttonMode = true;

}
}

 

The errors i get are the following: 

 

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at Untitled_fla::MainTimeline/dropIt()
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at Untitled_fla::MainTimeline/dropIt()

 

I dont know how to fix them.

Also on the code that has the psar i want it to go to scene bravo1, but it gets to the scene assigned to the previous inastance (trap), which is xana1.

 

Im desperate i really dont know how to fix it.

Thank you!!!

This topic has been closed for replies.
Correct answer kglad

you need to fix

 

if (MovieClip(this.root)) gotoAndPlay(1,"xana1") ;{
removeChild(trap); }

 

it's not clear what you're trying to do so it's not clear how to fix that, but you could eliminate that error message by using

 

if(trap.stage){

trap.parent.removeChild(trap);

}

 

instead of

 

removeChild(trap);

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 3, 2022

you need to fix

 

if (MovieClip(this.root)) gotoAndPlay(1,"xana1") ;{
removeChild(trap); }

 

it's not clear what you're trying to do so it's not clear how to fix that, but you could eliminate that error message by using

 

if(trap.stage){

trap.parent.removeChild(trap);

}

 

instead of

 

removeChild(trap);

Sofia5FCDAuthor
Known Participant
February 3, 2022

Thank you for your answer!

I did it and it removed the error but now it gives me more errors

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/dropIt()
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at Untitled_fla::MainTimeline/dropIt()

 

I attach a photo below so you can understand what game it is.

When i drop the table to target everything works fine

but when i drop the fish to the target iit gives me these errors and it isnt going to the scence i assigned it to. It goes to the same scene I have assigned the table to go.

 

What should i do?

Thank you very much!

Sofia5FCDAuthor
Known Participant
February 3, 2022

More specifically the 1009 error is 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/dropIt()[Untitled_fla.MainTimeline::frame241:24]