JavaScript, Passing and Using Variables

Mar 19, 2014

Hi Guys,

Having a small problem with executing JS in our Storyline files. Basically i am trying do a toggle function for turning a Close Caption screen on and off for our users (which Storyline doesn't seem to have functionally for).

So what i have currently is a project file with the following:

Variable named "ccCount"

Layer named "CC"

a Trigger stating:

Show Layer "CC" when timeline starts, if ccCount = 1

a Trigger stating:

Hide Layer "CC" when timeline starts, if ccCount = 0

Here is the JS:

var p = GetPlayer();

var ccOn=1;

var ccOff= 0;

var cc = p.GetVar(“ccCount″)

if (cc = 1)

{

   p.SetVar("cc", ccOff);

}

else

    p.SetVar("cc", ccOn);

}

I am executing that JS from a button added to the player (like adding an Exit button to it). The JS doesn't seem to work through this or on a button added to the content, is it my JS that's wrong? I cant even get one button to Trigger like a toggle button (i guess you can do that with a state change, but i want to move this functionally to the player, so i don't have to copy and paste the button into every slide and keep it out of the content). any help would be appreciated with this.

4 Replies
Helen Tyson

Hi Keith

I'm not a javascript expert, in anyway shape or form, but I've managed to create what I think you want without using it.

I've got a slide with a closed caption layer that is controlled by a true/false variable. The variable starts False and when the user click the button to open the captions it also adjusts the variable to True. If the user then closes the captions it also resets the variable to False.

Adding a trigger to the timeline of the slide to open the caption layer if the variable is True means that if the user moves on with the captions open they will remain open when they return to this slide, if they close the captions before moving on the slide reopens with the captions closed.

Hope this is what you were wanting to do and that it might simplify things for you, just bear in mind you need a new variable for each slide that contains captions.

Cheers

Helen

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