Skip navigation
Currently Being Moderated

Error Help..

Apr 13, 2012 11:06 AM

TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at AttackMC/frame25()


what do ii do?

What does this mean?


if ii put ...



trace("parent: " + parent);

trace("mc parent: " + MovieClip(parent));



to trace it out the following comes out...


parent: null

mc parent: null

TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at AttackMC/frame25()





ii am using Flash player 10


how do ii give it a parent.. so that it works..


In the library the movieclip is called Attack and then their is a linkage AttackMC


is that the problem?

  • Currently Being Moderated
    Apr 13, 2012 11:30 AM   in reply to AnimatedCircle

    I am going to guess that you removed the line addChild(Attack) from your code from earlier.  You originally said you added that to make it play, but that is not what it does,  What it does is adds it to the stage so that it then has a parent (the main timeline).  If you do not use the addChild() command, the movieclip will still play if you tell it to, and without a parent it will fail with the error you are getting.

    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 12:34 PM   in reply to AnimatedCircle

    It is as I suggested. 


                  var Attack:AttackMC = new AttackMC();


    With that line where it is you are likely creating hundreds of those AttackMC objects before you actually generate a hitTest.  But the only one that gets the addChild() working for it is the one that gets added when the hitTest passes.


    So the first of the hundreds that you create  that plays to its end will produce the error you are getting since it was never added to the stage.


    You do not want to be instantiating new instances every time that function gets called, and that function gets called at the frame rate of your file.  Just put a trace command in right after that line and see how many of those you end up creating before your hitTest finds a hit.


    You should declare that outside of the function and instantiate it only once inside the conditional.

    Mark as:
  • Currently Being Moderated
    Apr 13, 2012 7:32 PM   in reply to AnimatedCircle

    I already answered that in the last sentence of my last response.  You can do a little bit of both.  What you should do is think about what you need to do with it.  Where you have that line now you can see what it does.  You only want to create one when you need it. 


    I feel people learn from working things thru rather than being handed solutions, so that why I am not handing you the code that would fix it.  It is a simple change, involving a simple concept that you should get under your belt.  working thru it will help.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points