trying to generate a random number using javascript

Sep 24, 2014

Okay iv'e spent the past several hours trying to get this to work, following every tutorial iv'e found on the web step by step and not sure where i'm getting it wrong.

I want to have a button that when clicked it generates a random number between 1-10.

So these are the steps iv'e taken exactly from scratch....

(1) create a textbox

(2) click REFERENCE and create a new VARIABLE

(3) name the variable randnum (set it as a number, with a value of 0)

(4) create a trigger for the button

(5) set button so - when user clicks button, javascript is executed.

(6) add the following javascript:

var randomnumber = Math.floor((Math.random()*10)+1);

var player = GetPlayer();

player.SetVar("randnum",randomnumber);

iv'e attached the storyline file

Nate

7 Replies
Michael Hinze

Nate Grieve said:

Oh thankyou for testing it,

I actually plan to use this as a SWF file, but i won't be uploading it onto a server. Do you know if there is a way around it within articulate without uploading it onto a server?

The 'Publish to CD' option that Dennis had mentioned (I always forget about this option ) lets you run published content locally (off a hard drive or CD). Be aware that Storyline does not publisha single.swf file, but a bunch of files and folders/subfolders.

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