Javascript and Storyline 2

May 22, 2015

I am wondering if it's possible to push a javascript command to Storyline.

 

i.e. have a external timer script that when finished sends a command to SL2 alerting a close out prompt.

8 Replies
michael roddick

Thanks all. Steve if I say have a timer in an external JS file how do you push a command from it to SL? I would like the external JS file to communicate with SL, is this possible?

I am testing a low fidelity audio file to do this. I have a trigger to show an exit confirmation layer at the end of media. Then on the exit layer another to close the course at end of its media or start the base layer media over again if the learner chooses to continue. The only real downside to this effort is file weight with 2 blank audio files

Steve Flowers

The thread Jackson linked to is helpful for loading libraries into your header. To communicate between Javascript and Storyline's player, there are only a few simple methods available. Here's an example of how you'd send a value to Javascript:

var player=GetPlayer();
window.myVar=player.GetVar("StorylineVariable");

And here's how you'd send a value to the player into a Storyline variable:

var player=GetPlayer();
player.SetVar("StorylineVariable",1);

If you wanted to retrieve a number variable from SL and increment the value of the variable, it might look something like this:

var player=GetPlayer();
var myVar=player.GetVar("StorylineVariable");
myVar++;
player.SetVar("StorylineVariable",myVar);

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