Demos, Design Tips and Tricks

Random Number Generator

A little blast from the past. Before the random fortune teller and the random word generator, I started out pairing together Storyline and Javascript with this simple random number generator. It creates a whole integer between 1 and 10.

randnum

Click here to view

How to do this:

  1. Create a variable in storyline called “randnum”
  2. Add a trigger to execute Javascript when the generate button is clicked. Enter in this Javascript:

var randomnumber = Math.floor((Math.random()*10)+1);
var player = GetPlayer();
player.SetVar(“randnum”,randomnumber);

3. Add in a reference to the storyline variable (%randnum%) where the random number will be displayed.

Easy peasy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s