Persistent symbol javascript function problem

Hello!

I am having trouble getting a javascript function to work inside of my persistent symbol. I can get in all to work when it is not in a symbol but one of my functions does not work when it is in a persistent symbol, the other one does work. So I am confused. The addTensymbol works well but the timeInBoxSymbol is not working.

If anyone can help I would be very grateful.

Thanks!
scorer v2 with symbol.hype.zip (24.4 KB)

The symbol in effect is it’s own hype document so addressing it as if it were the main hypeDocument will not work.

In fact none of your functions are working correctly because of this.

The symbol TL timeline is within the symbol’s document scope so we need to reference the symbol first and target it in a similar way we do the main hypeDocument.
The boxsymbol is also inside the symbol and we have to target that accordingly.

Change your timeinBoxSymbol() to

		//-- Get the symbol instance
var scoreLine_ = hypeDocument.getSymbolInstanceById('score line')


//-- Target  a symbol instance's timeline
	var z = Number(scoreLine_.currentTimeInTimelineNamed('symbol TL'));
	var y = z * 10;
	 
	
		//--   symbol instance element -> child element
	scoreLine_.element().querySelector('#boxsymbol').innerHTML = (y).toFixed(0);

change the addTenSymbol() to

		setTimeout(function(){  
		var scoreLine_ = hypeDocument.getSymbolInstanceById('score line')

  scoreLine_.pauseTimelineNamed('symbol TL')
}, 1000);
3 Likes

Many thanks for this solution. I had suspected something a long these lines but after many attempts (and hours) at getting the syntax right I gave up. Have a great day and thanks again. You are very kind.

1 Like