Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error 2007

New Here ,
Feb 02, 2022 Feb 02, 2022

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
530
Translate
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

Community Expert , 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);

Translate
Community Expert ,
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);

Translate
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

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!

Translate
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

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]

Translate
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

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

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

you're welcome.

Translate
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

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.

Translate
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

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. 

Translate
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

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

Translate
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
Community Expert ,
Feb 03, 2022 Feb 03, 2022
LATEST

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

Translate
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