Copy link to clipboard
Copied
Hi there, I am having a little trouble figuring out how to correctly format this. The quotes turn the text green and normally you would hard code what scene you want to travel too. I want the scene to be "Scene X" where X = random number between 2 - 5
stop();
button_next.addEventListener( MouseEvent.CLICK, goToRandomFrame);
function goToRandomFrame( event:MouseEvent): void
{
var minFrameNb = 2;
var maxFrameNb = 5;
var randomFrameNb = minFrameNb +Math.floor( Math.random() * (maxFrameNb - minFrameNb + 1));
gotoAndPlay(1, "goToRandomFrame");
}
Hi,
You just need to compose the name of the scene.
In the example, that I have attached, my scenes are called "Scene 1", "Scene 2"... and so on.
In the event handler function, I compose the scene name using the random number. That's all! 🙂
...this.stop();
button_next.addEventListener( MouseEvent.CLICK, goToRandomFrame);
function goToRandomFrame( event:MouseEvent): void {
var minFrameNb:Number = 2;
var maxFrameNb:Number = 5;
var randomFrameNb:Number = minFrameNb + Math.floor( Ma
Copy link to clipboard
Copied
Hi,
You just need to compose the name of the scene.
In the example, that I have attached, my scenes are called "Scene 1", "Scene 2"... and so on.
In the event handler function, I compose the scene name using the random number. That's all! 🙂
this.stop();
button_next.addEventListener( MouseEvent.CLICK, goToRandomFrame);
function goToRandomFrame( event:MouseEvent): void {
var minFrameNb:Number = 2;
var maxFrameNb:Number = 5;
var randomFrameNb:Number = minFrameNb + Math.floor( Math.random() * (maxFrameNb - minFrameNb + 1));
var sceneName:String = "Scene " + String( randomFrameNb );
gotoAndPlay( 1, sceneName );
}
https://cloud.vectorworks.net/links/11e9b36e667b104c82270a7c60cb7e10/
Copy link to clipboard
Copied
Thankyou, works perfectly. A+