Skip to main content
Participating Frequently
March 3, 2013
Question

Debugging #2007 and #1009

  • March 3, 2013
  • 3 replies
  • 1095 views

Hi guys, almost done with my game, but I'm having some major problems regarding flash throwing 2 errors in the end-screen of my game.

Was wondering if anyone could help me and tell me where the problem is to be found? I'm a real AS3 newbie and my head has had a try at it for the last 1 hour or so. Ive tried to read up on what those errors really say, but i still havent managed to lurk out the problems. Would appriciated if anyone could download the "game", give it a run and see if you can see why Flash is throwing errors.

To "experience" the error, just start the game in Flash (so you can see the debugger), and let one of the objects flying from the roof hit you. You will then see an endgame screen and a hidious ammount of errors being thrown.

I've uploaded the file to one of my servers, and you can download the "whole package" here;  http://enavdebedre.com/itspill.zip . Its a .zip archive, size is about 11.4mb. Contains the whole project needed to run and debug.

Would really appriciate if anyone has any inputs to share on the problem.

Thanks!

Message was edited by: RedITYesterday Edited so it was a .zip archive instead of .rar!

This topic has been closed for replies.

3 replies

Inspiring
March 4, 2013

Also, on main timeline, there is an error on line 48. The following addition to moveChar function eliminates the error as well:

function moveChar(event:Event):void{

if(!mcMain){

                    return;

          }

// the rest of the code

}

Inspiring
March 4, 2013

There are tons of errors. As far as the first one on line 58 in Enemy class is concerned - you need to check for if _root.mcMain exists. So the line

if(hitTestObject(_root.mcMain)){

should be

if(_root.mcMain && hitTestObject(_root.mcMain)){

Because at some point of the game  _root.mcMain sieze to exist.

Also, it is an overkill to have a separate _root Object because, unlike in AS2, root is stable in AS3 and you can refer to it directly.

There are more errors there - you always need to check for objects existence in your code. I suspect there are some logical flows but I don't have time to debug more.

Ned Murphy
Legend
March 3, 2013

You'll increase your chances of getting help if you don't require people to look beyond your posting for the information they need to try to help solve your problem.  Not many are willing to download files.  If you could put the actual error messages in your posting that is a good start, as well as including any code that might be relevant to the errors.

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

Participating Frequently
March 3, 2013

Thank you again.

Ok, so im Assumeing that the problem is in fact that the object "- does not exist in the frame where that code is trying to talk to it" as you said it.

But, i've used "countermeasures" to work against this (removechild, eventlisteneres etc.) , and it still won't give up.
I think its the "HitTestObject" messing up, its trying to "hittest" with a object which is not in the next frame, but i haven't told it to keep checking.


Is there any way to stop the "hitTest" from running? like a "HitTest.stop" or something? Ive tried googling now but it doesent seem to help.

Relevant code:

//hit testing with the user

            if(hitTestObject(_root.mcMain)){

                //losing the game

                _root.gameOver = true;

                _root.gotoAndStop('lose');

            }

           

            if(_root.gameOver){

                removeEventListener(Event.ENTER_FRAME, eFrame);

                this.parent.removeChild(this);

            }

Relevant Errors;

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

    at flash.display::DisplayObject/_hitTest()

    at flash.display::DisplayObject/hitTestObject()

    at Enemy/eFrame()

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

    at flash.display::DisplayObject/_hitTest()

Does this make for better troubleshooting?

Ned Murphy
Legend
March 3, 2013

How are you defining "_root"?  That is an AS1/AS2 term and will not work in AS3.

If you are somehow legitimately defining _root, what is causing that code to execute mutliple times?  Is it inside a function named eFrame?

You can see if the object being targeted is coming up null if you use the trace() function just before that line.  Use trace(_root.mcMain) and see if it comes up null (or doesn't trace)