3 Replies Latest reply: Nov 20, 2011 5:08 AM by Ned Murphy RSS

    Error 1009. Whats wrong?

    Fumph Community Member

      Im not sure what the problem is here. I tried searching this, but it hasnt been very helpful. Every time I get to frame 15 of my first scene, Error 1009 pops up in the output panel.

       

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

      at shooter_fla::MainTimeline/frame15()

       

      Here is my code for that scene:

       

      import flash.events.MouseEvent;

      stop();


      combat.addEventListener(MouseEvent.CLICK, real);
      function real(e:MouseEvent):void{
      gotoAndStop(1, "Combat")
      }
      training.addEventListener(MouseEvent.CLICK, GoT);
      function GoT(e:MouseEvent):void{
      gotoAndStop(1, "Training")
      }

       

      Clicking to go to the Combat scene works fine, but going to Training doesn't work. I checked my spelling, and made sure this function isn't duplicated. I would really appreciate it if you could tell me whats wrong.

       

      Also, other people online said that this might happen because this is undefined, so if this means anything, please inform me.

        • 1. Re: Error 1009. Whats wrong?
          Ned Murphy CommunityMVP

          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 not in the display list

          - 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.

          • 2. Re: Error 1009. Whats wrong?
            Fumph Community Member

            I did debug it, but that did not help. As that only told me where the problem was, and that is not what I was after. Thankfully though, your fourth tip sparked an idea for a solution. Now it is up and running!

             

            Thank you

            • 3. Re: Error 1009. Whats wrong?
              Ned Murphy CommunityMVP

              I don't know why you say it didn't help... knowing where the problem is is the first step to solving the problem.  It tells you which object you need to investigate.  Solving the problem then requires checking to see why the object is not being seen by the code, which is where checking the different possibilities comes into play. 

               

              For instance, you say the fourth tip led you to solving it... that comes from having come to know from experience that when you animate an object into place, every frame instance of it will adapt whatever instance name you assign to it in the first keyframe.  So if you do not name it in the first keyframe, that lack of a name will be adpated by each successive keyframe instance of it in the animation regardless that you might have assigned a name at the end.