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

Make button load scene once the current scene is done

New Here ,
Aug 31, 2014 Aug 31, 2014

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

So, I have this code right here -

button1.addEventListener(MouseEvent.CLICK, goScene2);

function goScene2(event:MouseEvent):void {

  gotoAndPlay(1,"Scene 2");

}

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.

TOPICS
ActionScript
344
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
Guru ,
Sep 01, 2014 Sep 01, 2014

set a variable at the beginning of your movie:

var clicked:Boolean = false;

then in your MouseEvent set it to true

function goScene2(event:MouseEvent):void {

  clicked = true;

}

then in the 40th frame of your first scene:

if(clicked){

gotoAndPlay(1,"Scene 2");

}

else{

// continue the loop

gotoAndPlay(1,"Scene1);

}

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 ,
Sep 01, 2014 Sep 01, 2014

I'm getting an argument error -

Error #2108: Scene Scene1 was not found.

  at flash.display::MovieClip/gotoAndPlay()

  at MyMovie_fla::MainTimeline/frame40()

I have this for frame 1-39 -

"var clicked:Boolean = false;

button1.addEventListener(MouseEvent.CLICK, goScene2);

function goScene2(event:MouseEvent):void {

  clicked = true;

}"

And this for frame 40 -

"if(clicked){

gotoAndPlay(1,"Scene 2");

}

else{

gotoAndPlay(1,"Scene1");

}"

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
Guru ,
Sep 02, 2014 Sep 02, 2014
LATEST

"Scene1" is a name I made up for demonstration purposes, you have to exchange it with the name of your actual first scene

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