Only Continue Timeline That Meets a Condition

Hi,

I have made an example that is working with 4 buttons, but was wondering if there is an easier way of achieving the same thing when many more clickable items are added to the page. When a button is clicked the item linked to the button becomes visible, all other items should be invisible. When another button is clicked the item linked to it becomes visible and the previous item that was visible disappears from view… and so on. Code below and scene attached.

The list of the question is: How do you check for a condition on multiple timelines, in my instance if current time in timeline is 1, continue only that timeline.

Thanks

	var one = hypeDocument.currentTimeInTimelineNamed('1')
	var two = hypeDocument.currentTimeInTimelineNamed('2')
	var three = hypeDocument.currentTimeInTimelineNamed('3')
	var four = hypeDocument.currentTimeInTimelineNamed('4')
	
	if (one == 1) {
	
	hypeDocument.continueTimelineNamed('1', hypeDocument.kDirectionForward, false)

	}
	
	if (two == 1) {
	
	hypeDocument.continueTimelineNamed('2', hypeDocument.kDirectionForward, false)

	}
	
	if (three == 1) {
	
	hypeDocument.continueTimelineNamed('3', hypeDocument.kDirectionForward, false)

	}
	
	if (four == 1) {
	
	hypeDocument.continueTimelineNamed('4', hypeDocument.kDirectionForward, false)

	}

timelines.hype.zip (18.1 KB)

For anyone interested, this array seems to be working!

var timelines = ["1", "2", "3", "4"];

var time_value = 1;

for (i = 0; i < timelines.length; i++) {

if ( hypeDocument.currentTimeInTimelineNamed(timelines[i]) == time_value){

hypeDocument.continueTimelineNamed(timelines[i], hypeDocument.kDirectionForward, false);
}

}
1 Like