Skip to main content
March 8, 2013
Answered

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

  • March 8, 2013
  • 2 replies
  • 830 views

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.

This topic has been closed for replies.
Correct answer kglad

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

}

2 replies

Ned Murphy
Legend
March 8, 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.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 8, 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()));

}

March 8, 2013

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

March 9, 2013

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


Thank you so much!