7 Replies Latest reply on Aug 14, 2012 11:53 AM by kglad

    Strange Error When Setting Button to GoTo Next Frame

    shell4u2

      I am using CS5/AS3- I have one scene with 2 frames. The first frame has a submit button that plays a movieclip held in the second frame.

       

      I want to be able to press a button at the end of the movie that will take me back to the first frame of the main timeline

       

      In the second to last frame of the movieclip, I have a stop and a button that I want to take you to the next frame. In the next frame I have a it set to go back to the root. It is working correctly. However, I need the button on click to go to the last frame of the movie clip and it is erroring out.

       

      I have this code on the button:

       

      stop();

      kite_btn.addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void{

          nextFrame();    

      });

       

      This is the error I am getting:

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

                at kite_fla::kite_3/frame192()

       

      I have looked everywhere and the code is repeated and confirmed as correct...but the error is still there.

       

      Thanks in advance for your help

        • 1. Re: Strange Error When Setting Button to GoTo Next Frame
          kglad Adobe Community Professional & MVP

          in you 3rd sentence you mention a button at the end of the movie.  it's not clear what you mean by "movie".

           

          is that your movieclip?  is that your main timeline? 

           

          and where is that button?  in your movieclip?  on the main timeline?

           

          and you showed some code.  where is that code?  in your movieclip?  on your main timeline?  and is that code on frame 192?

          • 2. Re: Strange Error When Setting Button to GoTo Next Frame
            shell4u2 Level 1

            Yes there is a button at the end of my movieclip.

             

            One Scene- two frames. First frame plays movieclip which is held in second frame...all on main timeline.

            Movieclip ends on second to last frame of the movieclip timeline with a stop. There is a button in this frame as well that I want to set when you push the button it will take you to the next frame, which is the last frame on the movieclip timeline. That frame has code that sends you back to the first frame on the maintime, outside of the movieclip timeline.

             

            The button that I want set to take you to the next frame has this code on it:

             

            stop();

            kite_btn.addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void{

                nextFrame();   

            });

             

            This is the error I am getting:

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

                      at kite_fla::kite_3/frame192()

             

            Frame 192 is the frame in the movie clip that holds the button and the first code to advance it to the next frame onclick.

             

            Hope that is clearer

            • 3. Re: Strange Error When Setting Button to GoTo Next Frame
              kglad Adobe Community Professional & MVP

              where's the code?  if it's the main timeline, your have an incorrect reference to kite_btn needs to use the movieclip reference:

               

              yourmovieclip.kite_btn.etc

               

              if your code is on the movieclip timeline, it needs to be in the frame where kite_btn exists.  if it is, kite_btn is incorrect.

              1 person found this helpful
              • 4. Re: Strange Error When Setting Button to GoTo Next Frame
                shell4u2 Level 1

                Yes the button is on the movieclip timeline in frame 192, which is where the code is as well. The name of the button is kite_btn...so what would it be if that is incorrect?

                • 5. Re: Strange Error When Setting Button to GoTo Next Frame
                  kglad Adobe Community Professional & MVP

                  is that button part of a timeline tween?  if yes, that's the problem.  to remedy, remove the instance name kite_btn for all on-stage objects.  create a new layer with a keyframe at frame 192 and add your button to that keyframe and name it kite_btn in the properties panel.

                   

                  if no, does that button exist on any frame before frame 192?  if yes, remove that button from all frames clear all the keyframes in what used to be your button's layer, create the first keyframe where you want that button to exist, add your button and assign its instance name (kite_btn) in the properties panel.  create the remaining keyframes needed in your button's layer and do NOT remove your button and then re-add it from any keyframe.

                   

                  if no, attach a screenshot of your timeline showing frames 1 to 192 and the with your button selected on frame 192 and showing the properties panel.

                  • 6. Re: Strange Error When Setting Button to GoTo Next Frame
                    shell4u2 Level 1

                    You really are a genius! It was in a tween...fixed that and bang, it worked! Thank you so much <3

                    • 7. Re: Strange Error When Setting Button to GoTo Next Frame
                      kglad Adobe Community Professional & MVP

                      you're welcome.

                       

                      p.s.  please mark helpful/correct responses.