A way to simulate functions in Storyline

I come from the Flash/Flex/Actionscript school of thought, and since I have been starting to develop in Articulate, I have been a bit frustrated with the way variables and triggers are handled. One area in particular has vexed me - there was no real way to create reusable functions.

Well, there actually is a way of sorts. If you consider that layers on a slide can be considered their own "timeline", you can use these layers to "call" triggers when the layer is shown! You can even do this is a timed manner if that is your preference.

This is how I do it:

1) Create a global master slide - used for the main program interface.

2) On this master slide, create a new layer. This layer can be as short or long (time-wise) as you need it, but shorter is probably better most of the time.

3) Place your triggers that you want to call on this layer, to be executed when the timeline starts, or when the timeline reaches a point on the timeline that you set up (0.25 - 0.50 etc.).

4) Creating a trigger on the master slide that command this new layer to be hidden when the master slide's timeline starts. [I guess you really don't need this, as layers default to be invisible.]

4) Create another trigger on the new layer that sets the layer's timeline to be hidden when it completes. (This step is pretty important.) [This is actually set on the layer's properties, so you don't really need a trigger here.]

Now, when you want to call this "function", you have another trigger show the layer. [This "calling" trigger could come from a button or control, or even another trigger.] The layer is "shown", firing off the triggers contained within it. At the end of the layer's timeline it becomes hidden, ready to be used again.

Here is a bit of a deeper dive:

You can think of Storyline layers as being similar to movieClips on a layer in the Flash main timeline of a scene. The main timeline and the movieClip sitting on the main timeline run independently of each other. In Flash, if you want to stop the movieClip (on the main timeline) from running right away , you have to tell it to stop using Actionscript. In Storyline, the layer stays at the zero point on the timeline until the layer is actually shown. Even though we are not actually showing any visual content, the timeline for the layer is stopped at zero until we command it to be shown. Then, when the timeline runs to the end, and you have instructed it to be hidden, this layer will go back to the zero point on its timeline and wait - until it is commanded to be shown again.

In this scenario, you must think of a layer as not revealing visible content, but  revealing actionable content. And if you place this layer on a master slide, you can "call" it on any slide that uses this master slide. Of course, you can use this technique on any slide - this is just a matter of scope, where you want the function to be available for use. Using this on a master slide allows you a little more flexibility, and also will let you write this "function" once, and reuse it whenever you see fit. 

4 Replies
Steve Flowers

Hey Mark -

This method works pretty well. I've moved to using objects as functions as well. 

  • Create an object, hidden by default
  • Add triggers to the object with the event "when timeline starts"
  • Add a final trigger to hide the object

It doesn't matter where on the timeline your object appears. No mucking with timelines. When on the master slide, there's a limitation to controlling these objects. I side-step this limit by using variables and listeners to "remote control" the function. For example:

  • Create a number variable goNext (you could use a boolean I like using a number to simplify remotes through Javascript triggers)
  • Create a trigger on the master slide to jump to the next slide when the variable goNext changes.
  • Create a trigger on a button on the base slide to add 1 to the goNext variable. 
Mark Ramsey


Yes, I used some similar variable controls on some of my work to control things.

For slide branching, I am using two number variables, “slideNum” and “slideMax”. slideMax is set to the number of slides I want to traverse. I have a Back button and a Next button, which sets the value of slideNum. I have a trigger that fires whenever the slideNum changes, which (typically) is every time I click the Next button or Back button (assuming a linear set of slides 1 to slideMax.)

When the buttons are clicked:

-       Back Button: subtract 1 from slideNum if slideNum > 1

-       Next button: add 1 to slideNum if slideNum < slideMax 

This trigger show a layer that fires off these sub-triggers:

-       Set the state of the Back button to disabled in slideNum = 1, otherwize set it to Normal

-       Set the state of the Next button to Normal, unless slideNum = slideMax

-       Jump to slide 1 if slideNum = 1

-       Jump to slide 2 if slideNum = 2 etc.

This also works if I put up a custom menu to directly access all slides. No matter where in the program I am, if I set slideNum to a number, the slide will load and the controls will chase.

You’re right, you really don’t have to mess with timelines. I threw in that part about the timelines to get people to think in terms of timed functions. I was also trying to illustrate the idea of the play head for the timeline. There is no call back for these called “functions” [except the end of the timeline]–  another frustration – but If something needs to load, like a large video or web object, I could do a timed function at the end. This is not like having an event fire upon load completion, but you work with what you have. 

Thanks for your response!