Fake Random Number in SL2 Example

Dec 19, 2015

Back in my early Flash days, when I was just learning Actionscript 1(AS1), I couldn't figure out how to generate a random number with AS1. So I came up with this idea to add numbers to a variable inside of a flash movie clip(MC) as it looped. Each frame in the MC had a small line of code that just added 1 to the variable. At 15 frames per second, the variable went from 1 to 15 then back to 1 as it looped. When the user clicked a button, the MC would stop and the variable would be set to wherever it stopped. This was my "sort of" random number.

Today I have adapted this concept to SL2! This example is a way to “sort of” make a variable random in storyline without having to use JavaScript. It will set a variable according to where the slide layers stop looping when the user clicks the button.

You should be able to copy and paste this example slide into your course and just change the look of things when you use it.

If you want to adjust the variable range you will have to adjust the 2 slide layers to have more or less cue points. Zoom in on the slide layers to make the cue points as close as possible. You’ll also have to adjust the length of the slide layers to accommodate more or less cue points. And then finally add/subtract more/less triggers to add to the random number when the play head passes a cue point.

I wouldn’t use this for generating a number set that’s too big of a range. So if you want to get a larger number value, set a small range of numbers high values.

These same instructions are off to the side in the attached example.

2 Replies

This discussion is closed. You can start a new discussion or contact Articulate Support.