Fun uses for JavaScript in Storyline
The following sections will teach you about the fun uses of JavaScript in Storyline.
Generating a random number
Generating a random number may not be the most practical use for JavaScript in Storyline for educational purposes, but it has the potential to be useful and it's pretty easy to pull off.
For ease of use, download JavaScript7.txt
and copy/paste the script into the Storyline JavaScript field.
To achieve this effect, you will first want to design your slide. Here, we have a text prompt for the learner and a button, which will execute the JavaScript:
Next, access the Manage Project Variables panel and add a new variable with the following parameters:
- Name: randnum
- Type: Number
- Value: 0
Now that we have our variable created, we need to add a reference to the variable. This has been added next to the button:
Finally, we will add a trigger to the button that will execute the JavaScript needed to generate the random number. Add a new trigger to the...