How would you implement a "random grab bag" using Storyline?
Does Storyline retain the value of an internal variable? For example, what happens if you run a second (completely different) JavaScript trigger which references an internal variable in an earlier (first) JS trigger?
Looks like Wendy has popped in to assist you here and I just wanted to share our documentation as well. Could be helpful for you or anyone following along.
If you view an Articulate Storyline 2 course on your local hard drive (or send it to someone else to view on their local hard drive), you'll encounter security restrictions from the computer, web browser, Flash Player, and network that'll cause various features to fail. To properly test your published content and share it with others, upload it to the environment for which it was published. See this article for details.
How do you write JavaScript code that does not generate a random number every time you click a button or reload the slide, for example, if the first time is 3, the next time the number 3 is no longer displayed.
8 Replies
Hey, Mike -
Without some serious fakery (not really random at all just time varied) you'd need to resort to the JavaScript trigger. Here's an example of rounding:
http://community.articulate.com/forums/p/20726/114599.aspx#114599
To generate a random number between 1 and 10 and set a variable to that number, this should work:
var player=GetPlayer();
player.SetVar("randomVariable", Math.floor((Math.random()*10)+1););
//assumes you have a variable named randomVariable in your story
Thanks Steve.
Steve, while we're (more like "you are") at it,
How would you implement a "random grab bag" using Storyline?
Does Storyline retain the value of an internal variable? For example, what happens if you run a second (completely different) JavaScript trigger which references an internal variable in an earlier (first) JS trigger?
Hi Mijke,
here's a link to a previousquestion/answer on random numbers
Geert
Hi all,
I am using Javascript to randomize numbers in StoryLine 2. However I receive the message that Javascript support is not available while previewing.
How to overcome this problem ?
Hi Maria
you'll need to publish the file and upload to a webserver or LMS to view
Hello Maria and welcome to E-Learning Heroes :)
Looks like Wendy has popped in to assist you here and I just wanted to share our documentation as well. Could be helpful for you or anyone following along.
If you view an Articulate Storyline 2 course on your local hard drive (or send it to someone else to view on their local hard drive), you'll encounter security restrictions from the computer, web browser, Flash Player, and network that'll cause various features to fail. To properly test your published content and share it with others, upload it to the environment for which it was published. See this article for details.
How do you write JavaScript code that does not generate a random number every time you click a button or reload the slide, for example, if the first time is 3, the next time the number 3 is no longer displayed.
This discussion is closed. You can start a new discussion or contact Articulate Support.