36 Replies Latest reply on Aug 21, 2017 10:18 PM by kglad

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

    HibernateZz Level 1

      I am currently making a media player and everything was working fine before i put this code in the the first scene.

       

      btn_next.addEventListener(MouseEvent.CLICK, nextsong);
      function nextsong(event:MouseEvent):void
      {
                lastposition = 0;
                soundchannel.stop();
                btn.btn_pause.visible = false;
                trace("finished");
                isPlaying=false;
      
                gotoAndPlay(1,"Airy");
      }
      
      

      After you press the button it is supposed to jump to the scene "Airy" but i get this error message:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
                at player1_fla::MainTimeline/frame2()
                at flash.display::Sprite/constructChildren()
                at flash.display::Sprite()
                at flash.display::MovieClip()
                at flash.display::MovieClip/gotoAndPlay()
                at player1_fla::MainTimeline/nextsong()
      
      

      This error occurs after the button is pressed and the next scene begins playing. Im fairly new to action script 3.0 and im not sure what is wrong. When i run the debugger it points out this line of script:

       

      airybtn.addEventListener(MouseEvent.CLICK, playsound1);
      

      the function playsound1 is:

       

      function playsound1(event:MouseEvent):void
      {
                if (! isPlaying1)
                {
                          soundchannel1 = mysound1.play(lastposition,0);
                          airybtn.btn_pause.visible = true;
                          isPlaying1 = true;
      
                }
                else
                {
                          lastposition = soundchannel1.position;
                          soundchannel1.stop();
                          airybtn.btn_pause.visible = false;
                          trace(lastposition.toFixed(0), mysound1.length.toFixed(0));
                          isPlaying1 = false;
                }
      
                soundchannel1.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
      
                function onPlaybackComplete(event:Event):void
                {
                          lastposition = 0;
                          soundchannel1 = mysound1.play(0,0);
                          soundchannel1.stop();
                          airybtn.btn_pause.visible = false;
                          trace("finished");
                          isPlaying1=false
      
                }
      }
      
      

      PLease help me....

        • 1. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
          kglad Adobe Community Professional & MVP

          click file > publish settings > flash > tick "permit debugging" > ok.  retest.

           

          the problematic line number will be in the error message allowing you to pinpoint the object that doesn't exist when your code executes.

          1 person found this helpful
          • 2. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
            HibernateZz Level 1

            I did that and this is what it came up with:

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

                      at player1_fla::MainTimeline/frame2()[player1_fla.MainTimeline::frame2:58]

                      at flash.display::Sprite/constructChildren()

                      at flash.display::Sprite()

                      at flash.display::MovieClip()

                      at flash.display::MovieClip/gotoAndPlay()

                      at player1_fla::MainTimeline/nextsong()[player1_fla.MainTimeline::frame1:15]

            • 3. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
              Ned Murphy Adobe Community Professional & MVP

              Error messages are ordered such that the "at" lines are ordered closest to furthest from the problem, so you want to look at line 58 of frame 2 to find the problem.  If you are using scenes and only have one frame in scene 1, then frame 2 would be the first frame in scene 2

               

              If line 58 is the line you say was pointed to by the debugger, then chances are airybtn does not exist as far as your code sees it.

               

              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 declared but not instantiated

              - 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 (or a different name) assigned in the preceding frame(s).

              1 person found this helpful
              • 4. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                HibernateZz Level 1

                Ned Murphy wrote:

                 

                Error messages are ordered such that the "at" lines are ordered closest to furthest from the problem, so you want to look at line 58 of frame 2 to find the problem.  If you are using scenes and only have one frame in scene 1, then frame 2 would be the first frame in scene 2

                 

                If line 58 is the line you say was pointed to by the debugger, then chances are airybtn does not exist as far as your code sees it.

                 

                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 declared but not instantiated

                - 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 (or a different name) assigned in the preceding frame(s).

                What do you mean by declared but not instantiated?

                The instance name is correct as i copy and pasted from scene 1 and i checked it. Nothing is animated, it has the same name as the instance in scene 1.

                Im not sure what to do?

                • 6. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                  HibernateZz Level 1

                  there is nothing on line 58 in frame 2.... thats the problem

                  • 7. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                    Ned Murphy Adobe Community Professional & MVP

                    I'll let kGlad continue with trying to help, but to answer your question...

                     

                    var someMC:Movieclip;         // declared but not instantiated

                     

                    var someMC:MovieClip = new MovieClip();     // declared and instantiated

                    • 8. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                      HibernateZz Level 1

                      in that case the variable has been instantiated. here is the full script:

                       

                      import flash.media.SoundChannel ;

                      import flash.events.MouseEvent ;

                      import flash.events.Event;

                       

                       

                      var isPlaying1:Boolean = true;

                      var lastposition1:Number = 0;

                       

                       

                      var mysound1:airy = new airy() ;

                       

                       

                      var soundchannel1:SoundChannel = new SoundChannel() ;

                       

                       

                      soundchannel1 = mysound1.play(0,0);

                       

                       

                      soundchannel1.addEventListener(Event.SOUND_COMPLETE,

                      onPlaybackComplete);

                       

                       

                       

                       

                                function onPlaybackComplete (event:Event):void

                      {

                                lastposition1 = 0;

                                soundchannel1.stop();

                                airybtn.btn_pause.visible = false;

                                trace("finished");

                                isPlaying1=false;

                      }

                       

                       

                       

                       

                      airybtn.addEventListener(MouseEvent.CLICK, playsound1);

                      function playsound1(event:MouseEvent):void

                      {

                                if (! isPlaying1)

                                {

                                          soundchannel1 = mysound1.play(lastposition,0);

                                          airybtn.btn_pause.visible = true;

                                          isPlaying1 = true;

                       

                                }

                                else

                                {

                                          lastposition = soundchannel1.position;

                                          soundchannel1.stop();

                                          airybtn.btn_pause.visible = false;

                                          trace(lastposition.toFixed(0), mysound1.length.toFixed(0));

                                          isPlaying1 = false;

                                }

                       

                                soundchannel1.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

                       

                                function onPlaybackComplete(event:Event):void

                                {

                                          lastposition = 0;

                                          soundchannel1 = mysound1.play(0,0);

                                          soundchannel1.stop();

                                          airybtn.btn_pause.visible = false;

                                          trace("finished");

                                          isPlaying1=false

                       

                                }

                      }

                       

                       

                      btn_stop.addEventListener(MouseEvent.CLICK, stopsound1);

                      function stopsound1(event:MouseEvent):void{

                                if(isPlaying1)

                                {

                                          lastposition = 0;

                                soundchannel1.stop();

                                airybtn.btn_pause.visible = false;

                                trace("finished");

                                isPlaying1=false;

                                }

                      }

                       

                       

                      btn_replay.addEventListener(MouseEvent.CLICK, replaysound1);

                      function replaysound1(event:MouseEvent):void{

                                lastposition = 0;

                                soundchannel1.stop();

                                airybtn.btn_pause.visible = true;

                                trace("finished");

                                isPlaying1=false;

                       

                       

                                {soundchannel1 = mysound1.play(0,0);

                                          airybtn.btn_pause.visible = true;

                                          isPlaying1 = true;

                                }

                       

                      }

                       

                       

                       

                       

                       

                       

                       

                       

                      //-----All playlist button events-----//

                       

                       

                      //4 AM//

                      btn_4am.addEventListener(MouseEvent.CLICK, play4am1);

                      function play4am1(event:MouseEvent):void

                      {

                                lastposition = 0;

                                soundchannel1 = mysound1.play(0,0);

                                soundchannel1.stop();

                                airybtn.btn_pause.visible = false;

                                trace("finished");

                                isPlaying1=false;

                       

                       

                       

                       

                      }

                       

                       

                       

                       

                       

                       

                      stop();

                      • 9. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                        kglad Adobe Community Professional & MVP

                        do you have code in more than one layer of frame 2? 

                         

                        if yes, put all your code in one layer and retest and copy-paste the problematic line of code.  if no, take a screen shot showing your timeline at frame 2 with all its layers and showing the actions panel with all its code for that frame and the layer with your code.

                        1 person found this helpful
                        • 10. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                          HibernateZz Level 1

                          yes i have script on different layers but its only the volume control thats on a different layer, ill give it a go tho

                          • 11. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                            kglad Adobe Community Professional & MVP

                            put all your code on the same layer so you can get an accurate line number in your error message without doing arithmetic.

                            • 12. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                              HibernateZz Level 1

                              ok i put all the scripts in scene1 on  one layer and same with scene 2, to 2 lines that the debugger mentions have nothing on it at all.

                               

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

                                        at player1_fla::MainTimeline/frame2()[player1_fla.MainTimeline::frame2:30]

                                        at flash.display::Sprite/constructChildren()

                                        at flash.display::Sprite()

                                        at flash.display::MovieClip()

                                        at flash.display::MovieClip/gotoAndPlay()

                                        at player1_fla::MainTimeline/nextsong()[player1_fla.MainTimeline::frame1:114]

                               

                              frame2, line 30: {

                              frame1, line 114: [blank]

                               

                              im pretty sure it has something to do with the gotoAndPlay action as that is when the error started occuring.

                               

                              btn_next.addEventListener(MouseEvent.CLICK, nextsong);

                              function nextsong(event:MouseEvent):void

                              {

                                        lastposition = 0;

                                        soundchannel.stop();

                                        btn.btn_pause.visible = false;

                                        trace("finished");

                                        isPlaying=false;

                               

                                        gotoAndPlay(1,"Airy");

                              }

                              • 13. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                kglad Adobe Community Professional & MVP

                                attach a screen shot showing your timeline at frame 2 with all its layers showing and include the actions panel with all the code for frame2.

                                • 14. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                  HibernateZz Level 1

                                  screenshot.jpg

                                   

                                  and the script is:

                                   

                                  import flash.media.SoundChannel ;

                                  import flash.events.MouseEvent ;

                                  import flash.events.Event;

                                   

                                   

                                  var isPlaying1:Boolean = true;

                                  var lastposition1:Number = 0;

                                   

                                   

                                  var mysound1:airy = new airy() ;

                                   

                                   

                                  var soundchannel1:SoundChannel = new SoundChannel() ;

                                   

                                   

                                  soundchannel1 = mysound1.play(0,0);

                                   

                                   

                                  soundchannel1.addEventListener(Event.SOUND_COMPLETE,

                                  onPlaybackComplete);

                                   

                                   

                                   

                                   

                                            function onPlaybackComplete (event:Event):void

                                  {

                                            lastposition1 = 0;

                                            soundchannel1.stop();

                                            airybtn.btn_pause.visible = false;

                                            trace("finished");

                                            isPlaying1=false;

                                  }

                                   

                                   

                                   

                                   

                                  airybtn.addEventListener(MouseEvent.CLICK, playsound1);

                                  function playsound1(event:MouseEvent):void

                                  {

                                            if (! isPlaying1)

                                            {

                                                      soundchannel1 = mysound1.play(lastposition,0);

                                                      airybtn.btn_pause.visible = true;

                                                      isPlaying1 = true;

                                   

                                            }

                                            else

                                            {

                                                      lastposition = soundchannel1.position;

                                                      soundchannel1.stop();

                                                      airybtn.btn_pause.visible = false;

                                                      trace(lastposition.toFixed(0), mysound1.length.toFixed(0));

                                                      isPlaying1 = false;

                                            }

                                   

                                            soundchannel1.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

                                   

                                            function onPlaybackComplete(event:Event):void

                                            {

                                                      lastposition = 0;

                                                      soundchannel1 = mysound1.play(0,0);

                                                      soundchannel1.stop();

                                                      airybtn.btn_pause.visible = false;

                                                      trace("finished");

                                                      isPlaying1=false

                                   

                                            }

                                  }

                                   

                                   

                                  btn_stop.addEventListener(MouseEvent.CLICK, stopsound1);

                                  function stopsound1(event:MouseEvent):void{

                                            if(isPlaying1)

                                            {

                                                      lastposition = 0;

                                            soundchannel1.stop();

                                            airybtn.btn_pause.visible = false;

                                            trace("finished");

                                            isPlaying1=false;

                                            }

                                  }

                                   

                                   

                                  btn_replay.addEventListener(MouseEvent.CLICK, replaysound1);

                                  function replaysound1(event:MouseEvent):void{

                                            lastposition = 0;

                                            soundchannel1.stop();

                                            airybtn.btn_pause.visible = true;

                                            trace("finished");

                                            isPlaying1=false;

                                   

                                   

                                            {soundchannel1 = mysound1.play(0,0);

                                                      airybtn.btn_pause.visible = true;

                                                      isPlaying1 = true;

                                            }

                                   

                                  }

                                   

                                   

                                  //Volume Slider//

                                  import fl.events.SliderEvent;

                                  import flash.media.SoundTransform;

                                   

                                   

                                  var voltransform1:SoundTransform = new SoundTransform();

                                   

                                   

                                  sc.addEventListener(SliderEvent.THUMB_DRAG, changevol1);

                                   

                                   

                                  function changevol1(event:SliderEvent):void{

                                   

                                            voltransform1.volume = sc.value;

                                            SoundMixer.soundTransform = voltransform1;

                                  }

                                   

                                   

                                  //Back button- btn_back//

                                  btn_next.addEventListener(MouseEvent.CLICK, prevsong);

                                  function prevsong(event:MouseEvent):void

                                  {

                                            lastposition = 0;

                                            soundchannel1.stop();

                                            btn.btn_pause.visible = false;

                                            trace("finished");

                                            isPlaying1=false;

                                   

                                            gotoAndPlay(1,"4am");

                                  }

                                   

                                   

                                   

                                   

                                  //-----All playlist button events-----//

                                   

                                   

                                  //4 AM//

                                  btn_4am.addEventListener(MouseEvent.CLICK, play4am1);

                                  function play4am1(event:MouseEvent):void

                                  {

                                            lastposition = 0;

                                            soundchannel1 = mysound1.play(0,0);

                                            soundchannel1.stop();

                                            airybtn.btn_pause.visible = false;

                                            trace("finished");

                                            isPlaying1=false;

                                   

                                   

                                   

                                   

                                  }

                                   

                                   

                                   

                                   

                                   

                                   

                                  stop();

                                  • 15. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                    kglad Adobe Community Professional & MVP

                                    attach a screen shot showing your timeline at frame 2 with all its layers showing (which you did) and include (in the screenshot) the actions panel with all the code for frame2 (which you didn't do).

                                    • 18. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                      HibernateZz Level 1

                                      I am having trouble uploading the screenshot, i gave you the whole script though, isnt that enough?

                                      • 19. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                        kglad Adobe Community Professional & MVP

                                        no.  i can't see your line numbers and you're misreporting what's on the problematic line.

                                        • 21. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                          kglad Adobe Community Professional & MVP

                                          ok.  use my website to send an initial email.  in a follow-up, you'll attach an image:  www.kglad.com

                                          • 23. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                            Daniel Gimness Level 1

                                            Thanks for the plain English replay Ned! With my code, the error was as you mentioned:

                                            - is one of two or more consecutive keyframes of the same objects with no name (or a different name) assigned in the preceding frame(s).

                                             

                                            I had a button which was on two keyframes with different names. It would be really nice in the next version of Flash if Adobe could make some plain English error codes though!

                                             

                                            Dan

                                            • 25. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                              KING-OLE Level 1

                                              I am having a similar problem.

                                               

                                              Please excuse me if this is a stupid question, but I'm still new to flash/as3.

                                               

                                              I've modified a small game from the book I've been studing, and it works great.

                                               

                                              The player object was controlled by it's own class, and sitting directly on the stage.

                                               

                                              In the player class, it adds the eventlisteners for the keyboard to the stage (stage.addEventListener....).

                                               

                                              So, I changed it so this was level 1 in a bigger game.

                                               

                                              I moved all symbols and objects from the stage of my FLA into a movie class symbol I called Level01, which used the class Level01, which had the same code as the main class had before. I then created a new "main" class that adds the Level01 symbol to the stage when I press a start button.

                                               

                                              This all works fine, but my player class now gives me an error (like above) when calling the stage.addEventListener...

                                               

                                              I have tried eliminating stage, replacing it with this, parent, and a combination of those, but it doesn't work.

                                               

                                              What am I missing?

                                               

                                              If you need the source code, please let me know.

                                               

                                              Thanks,

                                               

                                              Ole

                                              • 26. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                Ned Murphy Adobe Community Professional & MVP

                                                You should show the code that is relevant to your problem.  If you are trying to target something when initially instantiating the object, it is possible you need to wait for it to be ADDED_TO_STAGE (an event) before attempting such targeting.

                                                • 27. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                  KING-OLE Level 1

                                                  Thanks Ned.

                                                   

                                                  That helped, but opened up for a new problem.

                                                   

                                                  My player won't jump anymore, so I need to do some debugging to figure out what's going on.

                                                   

                                                  Thanks for your help though.

                                                   

                                                  Ole

                                                  • 29. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                    clancy1 Level 1

                                                    i need help fast

                                                     

                                                    i'm an armature and i don't understand this, but when i run the debugger it shows me a line is no different to the lines around it.

                                                     

                                                    the error:

                                                     

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

                                                      at newgame4_fla::MainTimeline/frame2()[newgame4_fla.MainTimeline::frame2:39]

                                                      at flash.display::MovieClip/gotoAndStop()

                                                      at newgame4_fla::MainTimeline/m1b1()[newgame4_fla.MainTimeline::frame1:9]

                                                     

                                                    the debugger took me here and the arrow was on line 33. (which is in bold):

                                                     

                                                    stop();

                                                     

                                                     

                                                    var ScoreN = 0;

                                                     

                                                     

                                                    var ScoreR = 0;

                                                     

                                                     

                                                    iScoreN.text = ScoreN + " incorrect";

                                                     

                                                     

                                                    iScoreR.text = ScoreR + " correct";

                                                     

                                                     

                                                    n1s1.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s1.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s1.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s2.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s2.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s2.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s3.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s3.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s3.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s4.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s4.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s4.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s5.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s5.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s5.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                    n1s6.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s6.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s6.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s7.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s7.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s7.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                    n1s8.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s8.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s8.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s9.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s9.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s9.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s10.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s10.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s10.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s11.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s11.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s11.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s12.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s12.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s12.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s13.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s13.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s13.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s14.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s14.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s14.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    n1s15.addEventListener(MouseEvent.CLICK, siN);

                                                    n2s15.addEventListener(MouseEvent.CLICK, siN);

                                                    n3s15.addEventListener(MouseEvent.CLICK, siN);

                                                     

                                                     

                                                    r1s1.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s2.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s3.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s4.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s5.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s6.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s7.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s8.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s9.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s10.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s11.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s12.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s13.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s14.addEventListener(MouseEvent.CLICK, siC);

                                                    r1s15.addEventListener(MouseEvent.CLICK, siC);

                                                     

                                                     

                                                     

                                                     

                                                    function siN(event: MouseEvent): void

                                                    {

                                                      iScoreN.text = ++ScoreN + " incorrect";

                                                    }

                                                     

                                                     

                                                    function siC(event: MouseEvent): void

                                                    {

                                                      iScoreR.text = ++ScoreR + " correct";

                                                    }

                                                     

                                                     

                                                    this next code is the code for the button which when clicked makes the error come up

                                                     

                                                    stop();

                                                     

                                                     

                                                    Main_Button1.addEventListener(MouseEvent.CLICK, m1b1);

                                                     

                                                     

                                                    Main_discovery.addEventListener(MouseEvent.CLICK, m1b1);

                                                     

                                                     

                                                    function m1b1(event:MouseEvent):void

                                                    {

                                                      gotoAndStop(2);

                                                    }

                                                     

                                                    this code is the only code that relates to the instance mentioned in bold (n1s8)

                                                     

                                                    n1s8.addEventListener(MouseEvent.CLICK, iq8n);

                                                     

                                                    function iq8n(event:MouseEvent):void

                                                    {

                                                      nextFrame ()

                                                    }

                                                     

                                                    screenshot of timeline:

                                                    screenshot (in progress).JPG

                                                    please help thx

                                                    • 30. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                      TheShifrin Level 1
                                                      Props to kglad: Thank You!

                                                      1398983351.png
                                                      Thanks for the suggestion! My code works now!
                                                      • 32. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                        Jacksrock Level 1

                                                        Greetings and Salutations,

                                                         

                                                        The AS3 code works with the expected results,  it  starts in frame 1103 and ends on frame1485.

                                                        When the action ends at 1485, the OUTPUT window opens and  is populated with 20 of the following error codes:

                                                        ---

                                                         

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

                                                                 at A_fla::MainTimeline/onEnterFrame() [A_fla.MainTimeline::frame1103:3]

                                                        ---

                                                         

                                                         

                                                        AS3 code in frame 1103:

                                                        ---

                                                        addEventListener((Event.ENTER_FRAME,onEnterFrame);

                                                        function onEnterFrame(event:Event):void {

                                                             E_1.rotation +=  ;

                                                        }

                                                         

                                                        ------

                                                        It may be that the code is still running past the 1485 frame, and if so how can it be stopped?

                                                        ------

                                                        I have also converted the SWF file to an MP4 file which runs great.

                                                        I would like to avoid getting the error 1009.

                                                         

                                                          Please help, Thank you very much.

                                                        • 33. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                          kglad Adobe Community Professional & MVP

                                                          click file>publish settings>swf>and tick 'permit debugging' to get the line number with the problematic code so you can pinpoint the non-existent object.

                                                          • 34. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                            fliera32088659 Level 1

                                                            This error is coming because you have not removed event listeners while moving from one frame to another. You should remove all the `EventListeners` before moving into other stage by using `removeEventListener`.

                                                            • 35. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                              fauziah rabbani Level 1

                                                              [SWF] TUGAS_AKHIR1.swf - 1230028 bytes after decompression

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

                                                              at TUGAS_AKHIR1_fla::MainTimeline/frame1()[TUGAS_AKHIR1_fla.MainTimeline::frame1:10]

                                                              • 36. Re: TypeError: Error #1009: Cannot access a property or method of a null object reference.
                                                                kglad Adobe Community Professional & MVP

                                                                what's line 10 in frame 1 of your main tmeline?