3 Replies Latest reply on Oct 2, 2014 8:59 AM by Ned Murphy

    Go to a frame without jumping

    K7Phoenix

      Hi! I have a button and a MoveClip looping.

      Is it possible that if I press the button it lets the animaton finish and then goes to the next frame or stops?

       

      This is my code:

       

      on (release) { movieclipname.gotoAndStop(120) }


      But this jumps to the 120th frame, what I need is "play the rest of frames and stop at the last frame (120)"

       

      Here is my project if you want to take a look: https://www.dropbox.com/s/t68vde8qoc...utton.fla?dl=0

       

      I want to use this on a graphic aventure game.

      Thank you so much!

        • 1. Re: Go to a frame without jumping
          Ned Murphy Adobe Community Professional & MVP

          You could have the gotoAndStop(frame) command in the last frame of the animation.  The button you click sets the value to be used for the frame variable, with a default set for that next frame you mentioned

          • 2. Re: Go to a frame without jumping
            K7Phoenix Level 1

            I just started with ActionScript so I only know how to use basic scripts and I don't understand the last part, could you tell me the code I should use in the button?

            And what's the difference between use gotoAndStop(frame) in the last frame or use just a stop();

             

            Thanks again.

            • 3. Re: Go to a frame without jumping
              Ned Murphy Adobe Community Professional & MVP

              If the intention is to loop the animation until the button is clicked then the button code should set a variable for a conditional check in the last frame.

               

              var stopNow = false;  // in the first frame of the timeline

               

              on(release){ stopNow = true; }  // for the button

               

              in the last frame of the timeline...

               

              if(stopNow){

                   stop();

              }

               

               

              You should try to get away from using code "on" objects.  You should assign an instance name to the button and keep the code in the timeline instead of placing it on the button.  That way your code is easier to find and in the same place.  The timeline version of the code would be...

               

              btnName.onRelease = function(){  // btnName gets replaced with whatever name you use

                  stopNow = true;

              }