Random Numbers/Binary Chooser in Storyline...?

Nov 18, 2012

Hi,

Is it possible to create a "random number generator" using OOTB Storyline functionality, or would I need to venture into the realms of Javascript?

Want to create a Trigger that sometimes goes "odd", and sometimes goes "even". Perhaps would not therefore even need to be random numbers, just a choice between a binary decision - 1/0, Yes or No.

Does not really matter - the fun bit is what happens when the decision has been made

Bruce

23 Replies
Alexandros Anoyatis

Hi Bruce,

Out off the top of my head, you can do that by creating a set of empty slides in a new question bank. Each slide will exit to your next logical slide (outside those slides) and contain a trigger that assigns a value to a single variable. Then just use that question bank to jump to a random slide/question.

It should then generate the random value in the variable, so you should be good to go...

Hope it makes sense.

Alex

Bruce Graham

Thanks - but that is not quite what I am looking for....

What I am trying to do is create a decision maker.

A user hits a button - there are a few seconds of nothingness, and then a selection is made by SL - either a "Yes", or a "No".

Depending on that outcome, a Trigger fires off an action - there are two possible actions (animations...), yes, or no - each of which make different things happen on the screen.

Thanks again anyway.

Bruce

Alexandros Anoyatis

Well, your random decision is only random in terms of the outcome (i.e., you always know your initial value can only be a 0 or a 1). So since this random decision is output on a variable it can be made at any time. So in essence you could do what I described in my first email before your "miracle" slide runs (maybe use the same background etc) and then do what you have to do, with the random decision already made beforehand. Kinda like match fixing !

Having said that However, I was not aware this had to be a repetitive process. As it stands, You will run into problems there since revisiting a previously executed random question bank will always return the initial result. You may get away with it, if you could set a trigger to restart the course (since it's a one slide course). Hopefully this is not a deal breaker in your situation.

However, feel free to have a look at http://community.articulate.com/forums/p/13240/79321.aspx as it may be of assistance (I'd love to help but I am commuting at the moment).

Hope it helps,

Alex

Geert De Rycke

Hi Bruce,

here's a link to w3schools.

I've made the link point to the random generator, sorry but its in Javascript :(

Var player = GePlayer();

player.SetVar("your_SL_variable",Math.floor((Math.random()*10)+1));

Bruce, I'm not sure about the actual syntax, nevertheless this (when it works) should return you a random number between 1 and 10

Geert

Sasha Scott

If you only need it to be 1 or 0 you could do a quick hack using the timeline that doesn't involve Javascript. Loop the timeline of a slide, and have two identical versions of a picture or shape occupying a short time, one of which when clicked gives 1, the other of which when clicked gives 0. It changes so fast it seems to be random.

I've attached an example that's set to "hover" just so it's easier to see it working.

Note for some reason looping the timeline doesn't work for me at all if there's anything with more than one state on the base layer... That seems to break the looping somehow. You can have objects with different states on other layers though. Weirdness

Bruce Graham

OK...

So I now have a Variable set up called "RandNum" (set as Type = Number / Default Value = 0)

I have a button set to execute some Javascript when clicked:

Var player = GePlayer();

player.SetVar("RandNum",Math.floor((Math.random()*10)+1));

If someone can confirm that syntax, then what do I then need to do to display the number on my page?

I thought it was using a Reference but I cannot see how to make thsi work.

Help please!

Thanks

Steve Flowers

Hey, Bruce - 

Make sure you have your development folder added to the Flash Security Settings manager. The Flash player has a "feature" that prevents the player from interacting with the browser when run locally:

http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

Click the Edit Locations dropdown and add the folder your publishing to (you can add a parent folder or even clear your entire drive if you want to). It just allows this kind of interaction when running locally.

Steve Flowers

Yep, works great for me locally when published as CD. For some reason Chrome on my virtual machine isn't liking the security settings addition. Not sure if it's chrome or if it's the virtual machine path on Windows XP that's causing it. Works great on my Mac when run from the published folder as HTML. 

Betting Bruce's problem is the security settings. Adding that security setting or publishing to run as CD should fix it up.

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