I read through the blogs for the above references. But I need to know if there is a full API available online on in PDF where I can check which function does what.
I was trying to grab a value from the SL player for javascript use just now, and was running into some trouble. It worked fine for string variables, but not for numbers.
For example, I had two variables set up in Storyline: mySLTextVariable = "hello" mySLNumberVariable = 678
So while this worked:
var player = GetPlayer(); var javascriptTextVariable = player.GetVar("mySLTextVariable"); alert("the storyline text value is: " + javascriptTextVariable);
this did not:
var player = GetPlayer(); var javascriptNumberVariable = player.GetVar("mySLNumberVariable"); alert("the storyline number value is: " + javascriptNumberVariable);
After much head pounding, I finally got it to work by initializing the number variable in the javascript
var player = GetPlayer(); var javascriptNumberVariable = 0; javascriptNumberVariable = player.GetVar("mySLNumberVariable"); alert("the storyline number value is: " + javascriptNumberVariable);
Just wanted to share in case anyone else was running into the same problem.
5 Replies
There are more options available in the HTML 5 player but the Flash player is restricted to reading / writing variables from JavaScript.
var player=GetPlayer();
var grabValue=player.GetVar("storylineVariable");
player.SetVar("storylineVariable",javascriptVariable);
Hi Steve -
I read through the blogs for the above references. But I need to know if there is a full API available online on in PDF where I can check which function does what.
Steve pretty much hit them all http://www.articulate.com/support/storyline/javascript-best-practices-and-examples
Yep - that's all there is
var player=GetPlayer(); //GetPlayer establishes an object reference to the player
var grabValue=player.GetVar("storylineVariable"); //GetVar retrieves the value of a named variable within the SL player. One parameter.
player.SetVar("storylineVariable",javascriptVariable); //SetVar sets the value of a named variable within the SL player. Two parameters.
I was trying to grab a value from the SL player for javascript use just now, and was running into some trouble. It worked fine for string variables, but not for numbers.
For example, I had two variables set up in Storyline:
mySLTextVariable = "hello"
mySLNumberVariable = 678
So while this worked:
var player = GetPlayer();
var javascriptTextVariable = player.GetVar("mySLTextVariable");
alert("the storyline text value is: " + javascriptTextVariable);
this did not:
var player = GetPlayer();
var javascriptNumberVariable = player.GetVar("mySLNumberVariable");
alert("the storyline number value is: " + javascriptNumberVariable);
After much head pounding, I finally got it to work by initializing the number variable in the javascript
var player = GetPlayer();
var javascriptNumberVariable = 0;
javascriptNumberVariable = player.GetVar("mySLNumberVariable");
alert("the storyline number value is: " + javascriptNumberVariable);
Just wanted to share in case anyone else was running into the same problem.
This discussion is closed. You can start a new discussion or contact Articulate Support.