Skip to main content
Known Participant
February 2, 2022
Answered

Error 2007

  • February 2, 2022
  • 1 reply
  • 866 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

I fixed the other errors as well! Thank you again so much for your help!

Sofia5FCDAuthor
Known Participant
February 3, 2022

I managed to fix these errors by putting the code in the right place but the other scenes won't run the code and they don't come up with any error. 


Fixed that as well. Just needed to relocated the dots to the centre of the symbols!