Highlighted

Random number = random scene

New Here ,
Jul 30, 2019

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( Math.random() * (maxFrameNb - minFrameNb + 1));

    var sceneName:String = "Scene " + String( randomFrameNb );

    gotoAndPlay( 1, sceneName );

}

https://cloud.vectorworks.net/links/11e9b36e667b104c82270a7c60cb7e10/

TOPICS
Discussions

Views

202

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Random number = random scene

New Here ,
Jul 30, 2019

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( Math.random() * (maxFrameNb - minFrameNb + 1));

    var sceneName:String = "Scene " + String( randomFrameNb );

    gotoAndPlay( 1, sceneName );

}

https://cloud.vectorworks.net/links/11e9b36e667b104c82270a7c60cb7e10/

TOPICS
Discussions

Views

203

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 30, 2019 0
Participant ,
Jul 31, 2019

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/

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2019 1
Boomtown LATEST
New Here ,
Jul 31, 2019

Copy link to clipboard

Copied

Thankyou, works perfectly. A+

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2019 0