0
votes

So, lets say scene 1 has 40 frames. Someone clicks on the button to go to the next scene at frame 10. I want it to continue to frame 40, then change to the next scene. Keep in mind that the 40 frame scene is on loop, so it could loop 4 or 5 times, then someone clicks next scene. So, I want it to finish the loop, then go to the next scene.

I've been looking everywhere on how to do this, and can't find anything!

So, I have this code right here -

At the beginning of the movie (Frame 1-39), I have -

var clicked:Boolean = false;

button1.addEventListener(MouseEvent.CLICK, goScene2);
function goScene2(event:MouseEvent):void {
    clicked = true;
}

Then, on the last frame (frame 40), I have -

if(MouseEvent.CLICK){
gotoAndPlay(1,"Scene 2");
}
else{
gotoAndPlay(1,"Scene1");
}

It goes to scene 2, even if you don't click the button.

Thanks in advance!

1

1 Answers

0
votes

That's because the MouseEvent.CLICK variable is always truthy. It's the constant you use to bind a click event handler. I think you mean to use the clicked variable that you set to true in the click handler.

if(clicked){
    gotoAndPlay(1,"Scene 2");
}
else{
    gotoAndPlay(1,"Scene1");
}