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.