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

letting a cycle play to a given point before changing scenes

New Here ,
Aug 28, 2013 Aug 28, 2013

HI,
I'm new to this forum. I have a question. I have a two scenes. Scene 1 is a cycle 100 frames long. I have a button in the scene, and when I press it, I go to the next scene. I have been able to get this to work.
The problem is when I press the button it goes immediately to the next scene regardless of where it is in the animation, so it looks like a glitch. (Frame 50 of scene 1 is identical to frame 1 of scene 2)
How do I fix it, so that if I press the button that the animation will continue to play until it reaches frame 50 and then go to scene 2?

Thanks a lot for any help

Conor

TOPICS
ActionScript
550
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 , Aug 28, 2013 Aug 28, 2013

Create a Boolean variable in frame 1 that you use in a conditional in frame 50 and have that conditional process the command to go to the next scene.  When you click the button have it change the value of that variable.

//frame 1

var gotoNextScene:Boolean = false;

yourBtn.addEventListener(MouseEvent.CLICK, changeSceneVariable)

function changeSceneVariable(evt:MouseEvent):void {

        gotoNextScene = true;

}

// frame 50

if(gotoNextScene){

      gotoAndPlay(1, "scene2");

}

Translate
LEGEND ,
Aug 28, 2013 Aug 28, 2013

Create a Boolean variable in frame 1 that you use in a conditional in frame 50 and have that conditional process the command to go to the next scene.  When you click the button have it change the value of that variable.

//frame 1

var gotoNextScene:Boolean = false;

yourBtn.addEventListener(MouseEvent.CLICK, changeSceneVariable)

function changeSceneVariable(evt:MouseEvent):void {

        gotoNextScene = true;

}

// frame 50

if(gotoNextScene){

      gotoAndPlay(1, "scene2");

}

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
New Here ,
Aug 28, 2013 Aug 28, 2013

Hi Ned,

Thanks very much for this, it worked perfectly.

all the best

Conor

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 ,
Aug 28, 2013 Aug 28, 2013
LATEST

You're welcome Conor

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