Skip to main content
Participating Frequently
April 10, 2018
Answered

Change scene

  • April 10, 2018
  • 4 replies
  • 2528 views

Hello i know this question was before i checked most of the answers but it didn't helped me so i have this piece of code witch should get me on the scene2.So when i am pressing the proper button to go on the next scene (witch i don't get why i have to pressed twice) this error pop out:

TypeError: Error #1006: gotoAndStopscene2 is not a function.

at almost11_scene1_fla::MainTimeline/fl_ClickToGoToScene()

this is the code that i used it:

btn_bricks.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);

function fl_ClickToGoToScene(e:MouseEvent):void

{

MovieClip(this.root).gotoAndStopscene (1,"scene2");

};

I have done it to work once but it was working only with the debugger still had to press twice but it was going on the second scene and from there further but unfortunately i don't remember what i was changing but i am more than sure that it was this part :"MovieClip(this.root).gotoAndStopscene (1,"scene2");​"

I would love to make it work as soon as possible so please it's there someone who can actually figure it out what or where it's wrong ???

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Thank you for sharing your knowledge with me but still waiting to see the answer to that file why it's not working why that error


If you use Ctrl + Alt + Enter, Animate will only export the "scene1". The "scene2" won't be exported and therefore won't be available. So if your code try to access "scene2", you will get that error.

The default shortcut for testing a movie is Ctrl + Enter. Try to always use it.

Your file is correct. You're only using the wrong shortcut.

Got it?

4 replies

Colin Holgate
Inspiring
April 12, 2018

One other tip, if you turn on Permit Debugging in the Publish Settings, the error will then tell you which frame and which line has the problem:

Participating Frequently
April 12, 2018

Thank you  Colin that’s a good tip as well thank you so much guys for your help .

Participating Frequently
April 10, 2018

ok ok you guys are right but actually this was the error that the debug worked was running i could reach the second scene but when i am testing the file with that code from Joao i am getting this error:

ArgumentError: Error #2108: Scene scene2 was not found.

at flash.display::MovieClip/gotoAndStop()

at almost12_scene1_fla::MainTimeline/fl_ClickToGoToScene()

Colin Holgate
Inspiring
April 10, 2018

If you haven't edited the name of the scene, and it's what Animate names it initially, it would be "Scene 2" and not "scene2".

Participating Frequently
April 10, 2018

Yes I name it like that

Ned Murphy
Legend
April 10, 2018

I haven't visited AS3 in a while, but as far as I remember there was never a function/method called gotoAndStopscene...  just gotoAndStop.

Try replacing it and see if that error goes away.

JoãoCésar17023019
Community Expert
Community Expert
April 10, 2018

Hi.

This line:

MovieClip(this.root).gotoAndStopscene (1,"scene2");

The correct is:

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