Loop Example

I was plumbing the triggers (i.e. events) in Storyline to figure out how I could set variables during a possible "mouseUp" event. I had a fairly complex drag and drop scenario that didn't have standard feedback for correct and incorrect responses, and I wanted to reset variables to ther initial states in certain cases.

I found that there isn't a "mouseUp" event in Storyline; the closest I could get was a mouse Hover trigger, which I used (along with other items) to get my job done. But I was considering using a loop to check for values of variables at one point during this process - and I know, I know, using a loop to check for a variable's value is an awful way to do this, but I was getting desperate at a point in the process.

Anyway, I left the loop in place in the slide and stored it away because I might need something like it again. I think it would be useful for non-ending animations.

The trick is to use two layers as calling functions. I have a layer called Loop, which is 5 seconds long and has a rectangle that has a wipe-from-left transition animation attached to it (creating an isobar-type object.) I call a second layer, RestartLoop, at 4.99 seconds on the timeline, and I hide this current layer at the end of the timeline (these two points are important, but I'll explain in a second.) RestartLoop only lasts for a quarter of a second, but it shows [calls] the Loop layer once again at 0.01 seconds, and also hides itself at the end of its timeline. [You might be able to call Loop at the start of this timeline, but I erred on the safe side.]

You might ask, why don't I call Loop at the end of Loop's timeline? It won't work. The timeline has to complete in order to be called again, because there is only one instance of Loop on the timeline at any given instance. So we have to step outside Loop for a split second in RestartLoop in order to re-queue it.

You can use the Timeline reaches trigger in values other than the default ones. I've found that it will respond to hundredths of seconds fine; in this example, I try to get as close as I can to the end of Loop (4.99 seconds) and as close as I can to the beginning of RestartLoop (0.01 seconds) to keep the visual "blink" of the isobar to a minimum. You would probably only see the slight break in the isobar movement on the first cycle; by then it has been loaded into memory and should be fairly seamless.

It's important to know that if you re-use layers like this, over and over again, you have to hide each layer at the end of it's timeline in order for it to be "reset." If you don't hide it, Storyline won't be able to start it at the beginning of it's timeline. This is how I re-use bits of  "code" (such as it is in Storyline) to simulate functions.

I'm sure others have found out better ways to do animations in Storyline, but this is one way to simulate un-ending loops. If this is useful, then, you're welcome! 

[END NOTE: I have not tested this to see if it continuously re-loads the looped items, possibly creating a memory leak. I will leave it up you and/or Articulate to confirm or deny this possibility. I kind of think it's okay, though.]

4 Replies
Daniel Sposato (Philly)

Hey Mark,

Interesting example and topic! I have used loops in slide layers a good bit for some of the interactions I've made. They come in handy for a number of things and I know about some of the issues that can arise from using them.

In some situations I like to use a cue point for a loop so I can quickly adjust it for testing purposes. I recently created a matching game that loop's the enormous quantity of triggers required for it to work over 5 slide layers. It works great! Even the HTML5 version. It was a challenge, do to the lack of coding loops, functions, and other such Actionscript and JavaScript features.

I like to use loops in slide layers as it allows me to divide up triggers amongst them so I don't have to scroll through a whole lot of them on one slide layer. Scrolling is frustrating. And every time you add a new trigger it adds it to the bottom, so I often need to spend time arranging the order of the triggers.

After using Captivate for a year I have found SL2 to be a tool that allows me to spend more time developing ideas rather than fixing issues, so I'm not complaining.