Generate Random name JS query issue may be

Hi,

Taking help from this blog http://matthewbibby.com/random/ I tried to create a random name for the player, but the JS query doesn't run in a preview mode. I published it but in vain. What is it that I am missing?

Second, I tried hiding the player to get a playerless feeling, but I want my slides to stretch wide and fill the entire page. How to go about that too?

Help me!

Cheers

3 Replies
Matthew Bibby

Hi Zahra,

This article will show you how to hide the player.

The JavaScript wasn't working as it was looking for a Storyline variable called RandomWord however you've got on called RandomWarriorName.

So change your JavaScript from:

var words = ['Earthules', 'Earthador', 'Earthotter', 'Earthomort'];
var word = words[Math.floor(Math.random() * words.length)];
var player = GetPlayer();
player.SetVar("RandomWord",word);

To:

var words = ['Earthules', 'Earthador', 'Earthotter', 'Earthomort'];
var word = words[Math.floor(Math.random() * words.length)];
var player = GetPlayer();
player.SetVar("RandomWarriorName",word);

And all will be good on Planet Earth again...