JavaScript in Storyline 360

Manipulating Variables

Assuming you already know how to create a Project Variable, create a new trigger that executes when the timeline starts on the current slide. Open the script editor and reference the Player object.

const player = GetPlayer();

To access the value of a variable, you use the GetVar() method which accepts a variable name as a parameter in double/single quotation.

player.GetVar("myVar");

Assign a Project Variable to a local variable.

let myVar = player.GetVar("myVar");

To change or update the value of a variable, you use the SetVar() method which accepts two parameters. A variable name in double/single quotes and the new value.

player.SetVar("myVar",  100);

Calling a parent function

To call a parent function, first call the global variable parent then use the dot notation to access its properties and type the function name.

parent.myFunction();

Using variables in JSON object

To use a variable as a key in a JSON object, encapsulate the variable in square brackets [].

{
    [myVar]: //"add value here"
}