Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Go to a frame without jumping

Guest
Oct 02, 2014 Oct 02, 2014

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!

TOPICS
ActionScript
375
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 02, 2014 Oct 02, 2014

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

...
Translate
LEGEND ,
Oct 02, 2014 Oct 02, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 02, 2014 Oct 02, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2014 Oct 02, 2014
LATEST

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines