Random Numbers


I’ve been exploring how to use javascript more effectively within Adobe Captivate. It’s actually easier, and a bit more powerful, than I realized before.

RND # Generator

Please forgive the simple graphics – this is a quick proof of concept!

Using javascript, I was able to create a random variable between the numbers 1 and 4 (like a four sided die). Next, I needed to have a text box show that variable, as it changed.

This actually turned out to be incredibly easy! I didn’t even need to declare a function in javascript (though with a complex project there would be benefits of doing so). I defined the random number variable as “d4” – and the text box that needed changing was named “d4roll.” The code I wrote is below.

var d4 = (Math.floor(Math.random() * 4)+1);
d4roll = d4;

As you can see, it’s just two lines – the first, identifying what the variables number will be, and the second, declaring the text box to be equal to the variable.

So, when the triangle button on the bottom of the module is pressed, a random number between 1 and 4 appears on the scroll above!

When I first started with Adobe Captivate, it seemed like a more flexible version of powerpoint. I’m beginning to see the power and utility behind the software, and it’s opening a lot of avenues for what I want to create in the future.

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 )

Facebook photo

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

Connecting to %s