3 Replies Latest reply on Apr 18, 2012 10:34 PM by kglad

    help me please


      hi, how are guys


      first thing i wanna say iam so sorry because iam so useless in this forum  , am just asking without helping 



      here the problem i designed some games and i always get this error 1009 error i.ve read it in this  book (foundation game programming )  and i still cant understand what does he mean


      here (iam asking in the blue lines and the   problem red lines

      help me please it is realy confusing me in game programming)

      Adding and removing objects from the stage

      Before you look at the code of the game, I need to explain the new way in which classes are being initialized.

      Dungeon Maze Adventure has been planned as a multilevel game. If you want to add another

      level, it means that you have to remove dungeon one from the stage and add dungeon tow . This gets you


      into a tricky technical situation regarding how AS3.0 initializes objects in the Flash Player when the

      game runs. It’s an extremely important issue to be aware of because it will plague the development of

      your Flash games and give you countless sleepless nights if you don’t understand why it happens and

      how to solve it.


      Let’s take a look a look at this problem. When the published SWF of the game runs, it does two things

      (in this order):

      1. It initializes all the objects by running the constructor methods in their classes.

      2. It displays the objects on the stage. (It displays them one by one in the order in which they

      were dragged to the stage from the Library when you designed the game in the FLA.)what does he mean by saying display them on the stage?? because i cant see them without addchild method and he said the swf file display them??!!!!!!!!




      Here’s the issue: if the class’s constructor method includes a reference to the stage or an object that

      is on the stage that hasn’t yet been displayed, you’ll get an error message saying this: here i cant understand any single word!!

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


      If you’re adding objects to the game, there’s a good chance that many of those objects have to access

      the stage as soon as they’re created. They might need to do this to set stage boundaries or access the

      properties of other objects that are also on the stage. If they can’t find the stage object because they

      haven’t been added to the stage yet, AS3.0’s compiler will “throw its hands in the air” and you’ll see

      the preceding error message.

      To solve this problem, you need to initialize objects only when they they’ve been added to the stage,

      not before.





      i hope you guys can help me

      thank you