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

Timed scene switch event doesn't switch to the right scene

New Here ,
Apr 06, 2013 Apr 06, 2013

Basically I have a timer, and after one second it's supposed to change scenes to the scene named "Transport"

          MovieClip(this.root).gotoAndPlay(1, "Transport");

But it's not working. It keeps changing back to the scene I already was on. What am I doing wrong?

Header 1

//Transport

import flash.events.TimerEvent;

import flash.utils.Timer;

var timer:Timer = new Timer(1000, 1);

timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_14);

Transport.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

          timer.start();

          gotoAndPlay(29);

}

function fl_ClickToGoToScene_14(event:TimerEvent):void

{

          timer.stop();

          MovieClip(this.root).gotoAndPlay(1, "Transport");

}

TOPICS
ActionScript
697
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
Community Expert ,
Apr 06, 2013 Apr 06, 2013

why do you have a click listener for Transport?  that's a problem but what are you trying to accomplish with that code?

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 ,
Apr 06, 2013 Apr 06, 2013

I don't know, I don't know how to code so I'm essentially fumbling around in the dark.

But what I'm doing with that code is that I press a button, then it plays a few frames on the current scene and after 1 second it switches to another scene. Basically it plays an exiting animation then switches pages.

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
Community Expert ,
Apr 06, 2013 Apr 06, 2013

that's fine.  but

1. your button should NOT have the same name as any other object (like a scene name).  ie, rename your button

2. unless you have a stop() after frame 1 in your Transport scene, your main timeline will loop.  ie, use gotoAndStop:


MovieClip(this.root).gotoAndStop(1, "Transport");

or add a stop somewhere in your timeline where you want to stop after going to 1,Transport

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 ,
Apr 06, 2013 Apr 06, 2013

I renamed all by buttons to be Xxxx_button, thanks for the heads up. However I now get these errors:

http://i.imgur.com/CUVrDK4.jpg

My code is as such:

stop();

//Transport

import flash.events.TimerEvent;

import flash.utils.Timer;

var timer:Timer = new Timer(1000, 1);

timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_14);

Transport_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);

function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void

{

          timer.start();

          gotoAndPlay(29);

}

function fl_ClickToGoToScene_14(event:TimerEvent):void

{

          timer.stop();

          MovieClip(this.root).nextScene(1, "Transport");

}

//Økonomi

timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_15);

Økonomi_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_3);

function fl_ClickToGoToAndPlayFromFrame_3(event:MouseEvent):void

{

          timer.start();

          gotoAndPlay(29);

}

function fl_ClickToGoToScene_15(event:TimerEvent):void

{

          timer.stop();

          MovieClip(this.root).nextScene(1, "Økonomi");

}

//Skole

timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_16);

Skole_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_4);

function fl_ClickToGoToAndPlayFromFrame_4(event:MouseEvent):void

{

          timer.start();

          gotoAndPlay(29);

}

function fl_ClickToGoToScene_16(event:TimerEvent):void

{

          timer.stop();

          MovieClip(this.root).nextScene(1, "Skole");

}

//Miljø

timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_17);

Miljø_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);

function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void

{

          timer.start();

          gotoAndPlay(29);

}

function fl_ClickToGoToScene_17(event:TimerEvent):void

{

          timer.stop();

          MovieClip(this.root).nextScene(1, "Miljø");

}

//Verden

timer.addEventListener(TimerEvent.TIMER, fl_ClickToGoToScene_18);

Verden_button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_6);

function fl_ClickToGoToAndPlayFromFrame_6(event:MouseEvent):void

{

          timer.start();

          gotoAndPlay(29);

}

function fl_ClickToGoToScene_18(event:TimerEvent):void

{

          timer.stop();

          MovieClip(this.root).nextScene(1, "Verden");

}

NRK.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);

function fl_ClickToGoToWebPage(event:MouseEvent):void

{

          navigateToURL(new URLRequest("http://www.venstre.no/artikkel/47993/"), "_blank");

}

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
Community Expert ,
Apr 06, 2013 Apr 06, 2013
LATEST

i don't know where you got that nextScene code but i didn't suggest using that.

in any case, if you want to use nextScene, you need to use it correctly.  it accepts no arguments.  the timeline advances to the next scene and stops.  you cannot specify a frame nor scene name in that method.

to remedy, use the code i suggested or remove the arguments from nextScene().

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