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

Is it possible to make a button go to 1 of 3 scenes?

Guest
Mar 08, 2013 Mar 08, 2013

Is it possible to make a button go to 1 of 3 scenes? I'm making a animation and I need it to when you click the button it go to 1 of the 3 scenes for that button but it chooses 1 of those 3 scenes randomly. I'm new to actionscript, I do not know what I'm doing.

TOPICS
ActionScript
789
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

correct answers 1 Correct answer

Community Expert , Mar 08, 2013 Mar 08, 2013

label the first frame of each scene (eg, "frame1_scene1", "frame1_scene2" etc);

then you can use:

btn.onRelease=function(){

_root.gotoAndPlay("frame1_scene"+Math.ceil(3*Math.random()));

}

Translate
Community Expert ,
Mar 08, 2013 Mar 08, 2013

label the first frame of each scene (eg, "frame1_scene1", "frame1_scene2" etc);

then you can use:

btn.onRelease=function(){

_root.gotoAndPlay("frame1_scene"+Math.ceil(3*Math.random()));

}

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
Guest
Mar 08, 2013 Mar 08, 2013

Do I need to put anything into the parenthese?

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
Guest
Mar 08, 2013 Mar 08, 2013

I got a handler erroer on btn.onRelease+function(){

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 ,
Mar 08, 2013 Mar 08, 2013

There is no "+" sign like you show.  It is an "="

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 ,
Mar 08, 2013 Mar 08, 2013

just copy and paste that code.  assign your button an instance name of btn and assign those frame labels.

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
Guest
Mar 09, 2013 Mar 09, 2013

Thank you so much!

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 ,
Mar 09, 2013 Mar 09, 2013
LATEST

you're welcome.

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 ,
Mar 08, 2013 Mar 08, 2013

You can, but if you have the option of not using scenes you should do it.  Scenes and navigation tend to not mix well.

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