Javascript for multiple timelines

Wonder if anyone has any suggestions re this:
I have a scene that contains 4 buttons that trigger an animation containing seven more buttons. Each of those buttons reveal a new location shown on a map (each location is contained on its own timeline).
When one of the four buttons is clicked it triggers a new animation that plays any of the other three in reverse - clearing the stage for the new information.
At present the only way I can clear the map completely is to manually enter actions that play each of the locations in reverse - very time consuming.

So my question is this - can I generate some javascript that will speed up this process?

you’ll need
an array containing all timelinenames
var timlinesArray = [‘lsjehfghskd’, ‘kshegf’, ‘jgh’]
id for each element equal to corresponding timlinename,

onClick or on touchStart run:

var timelinesArray = ['one', 'two', 'three'];
    
    var currentTimelineName = element.id;
    
    for (var i=0; i < timelinesArray.length; i++)
    {
    
    var timelineName = timelinesArray[i];
    
    if(currentTimelineName === timelineName)
    {
    hypeDocument.continueTimelineNamed(timelineName, hypeDocument.kDirectionForward, true)
    }else{
    hypeDocument.continueTimelineNamed(timelineName, hypeDocument.kDirectionReverse, true)
    }
    
    }

will only work if i understood you right …

1 Like

Thank you, I will give that a go.

Perfect - works a treat.

Just noticed a slight hitch - yes it clears the named timelines but it also flashes up all those named in the function.

Example:

Button 1 - reveals 7 locations in a separate panel. When any of these are clicked they appear on the map.

Button 2 - also as above but is supposed to clear the locations from Button 1.

When I enter the function above it initially flashes up all of the timeline ids contained in the function. can I stop it doing that?

after all i guess you’ll have to post an example off your file. perhaps someone will give it a try then

ups …

change every true to false :slight_smile:

Thank you Hans, I'll try that.

works here :slight_smile:

Thank you again, that worked although I can’t see why a direction of “false” for reverse is logical - but then I can never get my head around JS. Just when I think I’m getting some understanding it trips me up!

Ian

The
hypeDocument.continueTimelineNamed()

Uses three arguments.

  1. timeline Name
  • play timeline in direction

  • can restart timeline