Loop JS function in Ad banner

Hi,

I’ve just upgrade to version 4. I had created a lot of ad banners in previons version that include a Javascript function for creating loops (3 times) and they worked perfectly. However, it doesn’t work anymore in v4. Am I missing something? My knowledge of Javascript is close to none! Here’s the code associate with that function:

		window.loopCounter++;
	if (window.loopCounter <= 2) {
hypeDocument.startTimelineNamed('loop', hypeDocument.kDirectionForward)
}

Many many thanks in advance,
Jean-Luc

Can you share your Hype document where this is failing so we can take a look? There’s a few threads and downloadable examples on how to do this also: Set number of loops is one.

Hi Daniel,

Here’s de Hype document. I grabbed the JS code somewhere in these forums.

Jean-Luc

Followme_Swing_300x250_EN.hype.zip (78.5 KB)

If you look at the developer console in the browser, you will see an error:

ERROR: timeline named 'loop' not found

You do not have a timeline named “loop” - just the Main Timeline. So your code should instead be:

hypeDocument.startTimelineNamed('Main Timeline', hypeDocument.kDirectionForward)
2 Likes

It’s working! Many many thanks for the quick answer!

Best regards,
Jean-Luc

1 Like