Using javascript to show a layer

Dec 05, 2023

Hi there,

My first question here :)

I am working with a storyline 360 project, creating a MicroGame. I'm wondering if i can show a layer, using javascript. I have tried this code:

var player = GetPlayer(); 
var layerName = "0101"; 
// Show the layer with the specified name var slide = player.GetPlayer().GetCurrentSlide(); var layer = slide.GetLayerByName(layerName); if (layer) { layer.Show(); // Show the layer } else { console.log("Layer '" + layerName + "' not found."); }

Basically i want to show the layer called 0101 when the timeline triggers the javascript.  But that doesn't seem to work.

I know that i can use a trigger inside storyline to show a layer, but since i will be working with 30 layers, i prefer not to write a trigger for every layer. I also would like to use this function in more projects and creating 1 javascript file will save me a lot of manual trigger creating. :)

So my question basically is: Can i trigger to show a layer with javascript?




1 Reply