Sometimes when I am poking around inside published courses trying to solve one puzzle a crazy idea will come into my head. This was one of those. I am not certain this particular code will be immediately useful to you, but hopefully it will spark a crazy idea in your head!
While trying to solve an issue with Storyline I recently noticed that the entire contents of each slide’s layers are in a single DIV element. This lets us easily target all the contents of a layer with our JavaScript.
To illustrate this I wrote this code to grab the first layer and set its opacity to 50%:
$(".slide-layer:eq(1)").css("opacity", 50);
So let’s take a moment to digest that.
I am using jQuery to find all the DOM elements with the slide-layer class. That would return an array of all the layers and I am only interested in the first one, so I add that eq(1). Then I set its CSS opacity to 50%. All in one line of code :-)
You can play with that demo here:
var o = GetPlayer().GetVar("layer_opacity_cow");
$(".slide-layer:eq(1)").css("opacity", o/100);
First, I get the value of the slider. Then, I set the layer’s opacity to that value.
Visit the eLearning Brothers Storyline Template Library for tons of Storyline layouts, interactions, and more.