hypeDocument is not defined or HYPE is not defined

Although I’ve looked at this topic: How to call hype js function from external HTML, it hasn’t helped in this specific instance.

What I’m trying to do:

I have many functions within my Hype document.
I copied them into its own .js file.
I have added that .js file to the resource folder.

What happens:

The .js file loads; however, the following error results:

Uncaught ReferenceError: hypeDocument is not defined

This invariably happens because within the code, I have used Hype’s api functions; such as, hypeDocument.goToTimeInTimelineNamed(9, priorTimeLine);

What I did:

Per the earlier post mentioned above, I replaced hypeDocument with HYPE.documents['See']. See is the name of my document.

What happened next:

Uncaught ReferenceError: HYPE is not defined

I don’t know what to try next. Could someone point me in a fruitful direction?

.cc: @Daniel

Running a Hype API function before a Hype document has loaded won't work. Here's a method to listen for the 'HypeSceneLoad` event. You would place your code in place of the // line.

function MyFunctions(hypeDocument, element, event) {
  // run your functions that require a loaded Hype scene here. 
}
if ("HYPE_eventListeners" in window === false) {
  window.HYPE_eventListeners = Array();
}
window.HYPE_eventListeners.push({
  "type": "HypeSceneLoad",
  "callback": MyFunctions
});

This method doesn't require your Document Name, so it's easily adaptable to run Hype functions when a Scene has been loaded in the same html page. As you probably know this won't work if your Hype document is insulated in an iframe. This technique uses a similar callback method.

2 Likes

its oot…

but how if symbolInstance is not defined ?

thank you

If you’re hitting an issue with a specific document, can you share that document?