5 Replies Latest reply on Jun 2, 2011 4:40 AM by Ned Murphy

    Flash Error #1009

    Zrej

      Hi,

       

      Can anyone help me with this error? Would like to know how to solve this error as it will keep popping out whenever i click on the play button of the game I'm creating.

       

       

       

       

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

      at index_fla::MainTimeline/frame2()

      at flash.display::MovieClip/gotoAndStop()

      at index_fla::MainTimeline/clickPlay()

        • 1. Re: Flash Error #1009
          Filmzaddict

          It probably means that something inside the handler for button click event isnt properly initialized at the time you are clicking your button.

          1 person found this helpful
          • 2. Re: Flash Error #1009
            Zrej Level 1

            Erm, okay, but how do you actually check it? Cause i went through the codes a few times, but nothing seems to be missing..

            This was what i typed:

             

             

            stop();

             

            play_btn.addEventListener(MouseEvent.CLICK, clickPlay);

             

            function clickPlay(e:MouseEvent):void

            {

            gotoAndStop(2);

            play_btn.removeEventListener(MouseEvent.CLICK, clickPlay);

            }

            • 3. Re: Flash Error #1009
              Filmzaddict Level 1

              I dont know how your whole project looks like, but just for the sake of trying.... do this:

               

              //first assign the event listener... .then stop the play

              play_btn.addEventListener(MouseEvent.CLICK, clickPlay);

              stop();

               

              function clickPlay(e:MouseEvent):void

              {

              //first remove event listener, then goto and play

              play_btn.removeEventListener(MouseEvent.CLICK, clickPlay);

              gotoAndStop(2);

              }

               

              you are doing this in Flash IDE using the timeline? Its been a while since i ve been using the timeline.

              • 4. Re: Flash Error #1009
                Zrej Level 1

                Hmmm, i just tried but seems like the problem still persists.. Hmm, I'm using timeline to do it. Would external file works better?

                • 5. Re: Flash Error #1009
                  Ned Murphy Adobe Community Professional & MVP

                  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.

                  Just as an example, if that was all the code you had, then it would be most likely that your play_btn is what the code doesn't see.