Skip to main content
Participant
Apr 6, 2013 6:20 PM UTC
Question

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

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");

}

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

kglad
Community Expert
Community Expert
Apr 6, 2013 6:28 PM UTC

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

Translate
Participant
Apr 6, 2013 6:31 PM UTC

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
kglad
Community Expert
Community Expert
Apr 6, 2013 7:29 PM UTC

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