JS loading order


(Darren Hayles) #1

Hi all, i’d like to load up an initial piece of JS ‘on scene load’ that loads before any JS runs inside many of it’s child symbols.

Is there anyway to force the ‘On Scene Load - Action - Run Javascript’ to load first before an ‘On Symbol Load’ Action - Run Javascript’?

Thanks
Darren


(Hans-Gerd Claßen) #2

There’s also a ‘HypeDocumentLoad’-event. you can attach an action in the head-element. Have a look in the js-documentation …


(Darren Hayles) #3

Thanks for this, I’ve kinda got it working insomuch as that I can make it trigger my function using the following line in myCallback:
hypeDocument.functions().initVideo(hypeDocument, element, event);

However my function initVideo() no longer returns the inner elements of my symbol when I call:
hypeDocument.getElementById(‘videoContainer0’);

So now I can no longer target my class elements within using:
hypeDocument.getElementById(‘videoContainer0’).getElementsByClassName(‘video’)[0];

I am presuming that his has something to do with not knowing what scene my element is in (although there is only one), but I now can’t seem to find a way of targeting the elements correctly.

All works correctly if I load my function initVideo() on the first frame of my timeline.


(Hans-Gerd Claßen) #4

after all: it’s always good practise to post a file along with the question. my answer could not fit your needs because those are unclear … give it a try :slight_smile: