A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to fix error #1009?

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    13

    How to fix error #1009?

    Hi there I have a problem with this error #1009!
    I am making a platform game and I can not fix some bugs.

    When I use the debugger it says:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at PlatformGame/checkCollisions()[D:\game\PlatformGame.as:2445]
    at PlatformGame/gameLoop()[D:\game\PlatformGame.as:951]".

    On line 2445 in the function checkCollisions() in my as3 file is the following code:

    Code:
       line 2445:                      if (hero.mc.hitTestObject(boss.mc))
       line 2446:
       .				{ 
       .					if (hero.hit && hero.direction == boss.direction)
       .					{
    					Score_Font_Enemy.Health_Bar.width -=2.5;
    						bossLives--;
    						BossDie();
    					}else if(hero.hitted){
    						
    						} else {
    						heroHitted();
    					}
    				}
    I can't figure it out. I know that "boss.mc" is null but don't know how to fix it. The mc on the stage has its reference name "boss". This error happens when I enter the frame with the boss.
    Thanks for the help

  2. #2
    flip-flopper scottPadgett's Avatar
    Join Date
    Jan 2005
    Location
    Boston
    Posts
    425
    Sounds like it's saying either hero or boss themselves are null at this point. Comment out code until you find which is the offender. Then you can wrap this code in a conditional that only allows the code to execute if the offender is NOT null... That should get rid of the compile error.
    :: scott ::

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    If boss.mc is null you need to look at the rest of your movie script(s). First of all what does trace(boss); give? I don't know you are using classes or how you add your objects, because that will also determine your syntax.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    Dec 2008
    Posts
    13
    Hi again...
    I actually fixed it. The object boss was called after a previously called
    object and I just replaced their places.
    Really thanks for your replies.

    BTW I can not get rid of this error because it appears
    sometimes in my code in a places that are already fixed.
    I want to ask is there a way that you can run your game or
    project ignoring this error (I mean you can run it without showing you that you have error)?

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You can bypass those errors by placing those lines in a try-catch expression. The error will also be displayed but does not affect the movie. However, if you can avoid that avoid it.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center