Error 2007

New Here ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

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!!!

TOPICS
ActionScript , Code , Error , How to

Views

71

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

correct answers 1 Correct answer

Adobe Community Professional , Feb 02, 2022 Feb 02, 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);

Likes

Translate

Translate
Adobe Community Professional ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

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);

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 ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

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!

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

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]

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

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

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

you're welcome.

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

I just tested again to see if the code works on other scenes too and it returns these exact errors i mentioned above and the other scenes dont work :(. Sorry for bothering you again. I tried to remove the fish and the marker objects when for exaple the table hits the target but this doesnt work.

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

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. 

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

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

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 ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

LATEST

sounds good. it's always rewarding to fix problems.

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