The way I do this is with a variable change. Since you can setup triggers within Storyline to "listen" for changes to variables, incrementing a number and passing that back into Storyline can act as a trigger from JavaScript to Storyline.
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
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);
8 Replies
Hi Michael! Check out our documentation here on JavaScript Best Practices and Examples.
Perhaps others in the community will be able to assist as well.
Here is another topic about timers in storyline.
Hey Michael -
The way I do this is with a variable change. Since you can setup triggers within Storyline to "listen" for changes to variables, incrementing a number and passing that back into Storyline can act as a trigger from JavaScript to Storyline.
Thanks for sharing that as well Jackson :)
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
Heres another potentially relevant topic.
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:
And here's how you'd send a value to the player into a Storyline variable:
If you wanted to retrieve a number variable from SL and increment the value of the variable, it might look something like this:
thanks everyone
This discussion is closed. You can start a new discussion or contact Articulate Support.