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

What is the code to insert in the Actions window, to make clicking a button go to a scene and frame in Flash CC?

Explorer ,
Jun 24, 2014 Jun 24, 2014

What is the code to insert in the Actions window, to make clicking a button go to a scene and frame in Flash CC?

Also, how can I do this w/o clicking any button?

This is the current code snippet that is failing:

stop();
button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_8);
function fl_ClickToGoToScene_8(event:MouseEvent):void{
  MovieClip(this.root).gotoAndPlay(1, "Scene 1");
}

m.gisser@nydesign.com

TOPICS
ActionScript
457
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
LEGEND ,
Jun 24, 2014 Jun 24, 2014

There is nothing wrong with the code you show as written.  Are you getting any error message?  IF the code is already in the main timeline you do not need to target the root at all, but as written it should not err anyways.  Try putting a trace in the function to see if it is being called...

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_8);

function fl_ClickToGoToScene_8(event:MouseEvent):void{
     MovieClip(this.root).gotoAndPlay(1, "Scene 1");
     trace("function is called");
}


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
Explorer ,
Jun 24, 2014 Jun 24, 2014

Ned,

This Action Script worked in Flash CS5.5 but not in the new Flash CC.

How can we flag developers to this inconsistency?

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
LEGEND ,
Jun 24, 2014 Jun 24, 2014

I don't see that issue when I recreate a scenario using the code you show.   I place the button in a movieclip in a second scene and assign the code to it.  When I run the file and the second scene comes into play and I click the button it returns to restart scene 1.  I used the new Flash CC 2014 to test it.   I do not see the inconsistency you say you see, though I do not have CS5.5 working to compare to. 

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
Explorer ,
Jun 25, 2014 Jun 25, 2014

Ned, Can you send me the code I would use to go to a scene/frame  w/o using a button, just a timeline event. Thanks.

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
LEGEND ,
Jun 25, 2014 Jun 25, 2014

You already have it, just pull it out of the function...

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

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
Explorer ,
Jun 25, 2014 Jun 25, 2014

So all my script would have is this below?

stop();

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





Thank you for your help.

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
LEGEND ,
Jun 25, 2014 Jun 25, 2014
LATEST

The stop() wouldn't make much sense since the line after is defeating its purpose.

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