Copy link to clipboard
Copied
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
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");
}
Copy link to clipboard
Copied
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");
}
Copy link to clipboard
Copied
Hi Ned,
Thanks very much for this, it worked perfectly.![]()
all the best
Conor
Copy link to clipboard
Copied
You're welcome Conor
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more