Start one timeline when some other timelines were finished

Hi everyone~ I’m doing a game project now but with some troubles.
Here’s the demo: (240.8 KB)

I made 7 timelines, when I tap the butterfly1, the timeline"butter 1" is starting. The tap order is random because I couldn’t know which butterfly the users tap first.

I’d like to know how to do this : When the timeline “butter1”~ “butter6” were all finished (which means that all butterflies are fly out), then the timeline “result” will start.

I need your help~~~~Thank you very much!

you can attach this script at the end of each butterflytimeline:

if(hypeDocument.hasOwnProperty('customData') === false)
	hypeDocument.customData = {};
	if(hypeDocument.customData.hasOwnProperty('_butter') === false)
	hypeDocument.customData._butter = [];
	hypeDocument.customData.countOfTimelinesToBeFinished = 6;
	if(hypeDocument.customData._butter.length === hypeDocument.customData.countOfTimelinesToBeFinished-1){
	hypeDocument.startTimelineNamed('result', hypeDocument.kDirectionForward)

@h_classen I solved it too :wink: (289,2 KB)

Runnig this at the end of each timeline “checkEnd” …

	var butter1 = hypeDocument.currentTimeInTimelineNamed('butter1') == hypeDocument.durationForTimelineNamed('butter1');
	var butter2 = hypeDocument.currentTimeInTimelineNamed('butter2') == hypeDocument.durationForTimelineNamed('butter2');
	var butter3 = hypeDocument.currentTimeInTimelineNamed('butter3') == hypeDocument.durationForTimelineNamed('butter3');
	var butter4 = hypeDocument.currentTimeInTimelineNamed('butter4') == hypeDocument.durationForTimelineNamed('butter4');
	var butter5 = hypeDocument.currentTimeInTimelineNamed('butter5') == hypeDocument.durationForTimelineNamed('butter5');
	var butter6 = hypeDocument.currentTimeInTimelineNamed('butter6') == hypeDocument.durationForTimelineNamed('butter6');
	if(butter1 && butter2 && butter3 && butter4 && butter5 && butter6){
		hypeDocument.startTimelineNamed('result', hypeDocument.kDirectionForward)

:ghost: :slight_smile:

1 Like

Wow thank you all~!!! It’s wonderful, I can do other scenes now~ :relaxed::relaxed:

1 Like

Got it!! Thank you very much! You help me a lot!~~~ :blush::blush:

Here is a even smaller function …

var done = function(name) {
	return hypeDocument.currentTimeInTimelineNamed(name) 
	== hypeDocument.durationForTimelineNamed(name);
if(done('butter1') && done('butter2') && done('butter3') && 
   done('butter4') && done('butter5') && done('butter6')) {
	hypeDocument.startTimelineNamed('result', hypeDocument.kDirectionForward)
1 Like

I like that customData is already getting adopted (even before Hype 4). Nice°

It’s cool~ I try it and it’s great~~! It seems that I really need to learn about javascript more.
Thank you and @h_classen , you help me a lot! :grinning:

1 Like