Jump to a specific scene based on combination of timelines that have run

Hello everyone

Does anyone know a simple javascript function that will choose a scene based on which combination of timelines have run? In my simple example there are three coloured boxes. For example, if the red and blue box timelines have been triggered i would like to jump to scene redblue on the jump to scene button but if only the red timeline has been triggered it would jump to the red scene etc etc.

Many thanks to anyone who can help.

Simonscene on timeline combo.hype.zip (27.4 KB)

Have a look at my answer here.
Get the feeling the concept would lend itself to this..

Thanks for the response but I don’t think that’s quite what I’m after. I need to jump to particular scene based on which combination of timelines have been triggered.

I understand.

And the concept of the code that registers selection I would expect be adapted to do what you want.

You would use Timeline Actions at the end of each timeline for the boxes to call and register itself with the adapted code.

I’ve tried using the end time in each timeline as a variable and using the total (y) to choose which scene it jumps to on a mouse click of the button. It does not work but I’m stumped.

Any help is greatly appreciated.scene on timeline combo.hype.zip (27.8 KB)

What showed up for me regarding the code not running properly for the “SceneSelector” function is You are missing a bracket on line 39 (missing bracket shown & highlighted in attached file).

Missing Bracket


Also and this will not throw an error but give you bad results.

In javascript equal to should be




The latter being of same type i.e a number is not converted to a string type before comparison.

The more common equal to is ‘==’ and what you should use here.

A single equals symbol


is the equivlent od set to


In this case you could use a simple object for your numbers rather than a timeline duration.
This will give you a bit more flexablity.

Each timeline has a Time line Action at the end

which calls: iRan() function.

    	//init ( run this bit  eonce)
	if(typeof hypeDocument.customData.timelinesRan == 'undefined' ){
	//-- we will add the timeline name here so we only count it once
	hypeDocument.customData.timelinesRan = []
	//-- this will be our counter
	hypeDocument.customData.timelinesCounter = 0
	//-- always run below
	//--   timeline names and values
	var runList = {'bluetl':5,'greentl':1,'redtl':3}
	//-- which timeline called this function
	var  timelineName = event.timelineName
	var thisTimelinenumber = runList[timelineName]

	//-- timeline name is not in array
	if (!hypeDocument.customData.timelinesRan.includes(timelineName)){
	//-- add timeline name  
	//-- sum up the total
	hypeDocument.customData.timelinesCounter += thisTimelinenumber 

Then change your other function to

	var result = hypeDocument.customData.timelinesCounter
	if (result == 1) {
		hypeDocument.showSceneNamed('green', hypeDocument.kSceneTransitionCrossfade, 1.1);	
	}	else if (result == 3) {
		hypeDocument.showSceneNamed('red', hypeDocument.kSceneTransitionInstant, 1.1);
	}	else if (result == 5) {
		hypeDocument.showSceneNamed('blue', hypeDocument.kSceneTransitionCrossfade, 1.1);
	}	else if (result == 4) {
		hypeDocument.showSceneNamed('redgreen', hypeDocument.kSceneTransitionCrossfade, 1.1);
	}	else if (result == 6) {
		hypeDocument.showSceneNamed('greenblue', hypeDocument.kSceneTransitionCrossfade, 1.1);
	}	else if (result == 8) {
		hypeDocument.showSceneNamed('redblue', hypeDocument.kSceneTransitionCrossfade, 1.1);
	}	else  {
		hypeDocument.showSceneNamed('redgreenblue', hypeDocument.kSceneTransitionCrossfade, 1.1);

scene on timeline combo 2v2.hype.zip (53.9 KB)


That’s great. Now my timelines can be of any length- thank you so much!

1 Like