Hi, I have just been trying out the new Sizmek Export Script and have been getting an error in so much as the Export Script is loading my HYPE document twice.
Please see the attached file. I have included a JS alert(); on the first 'On Scene Load' which should only run once, however when I use the Sizmek preview it runs through twice.
I have identified the following JS code that has been added to the HTML head by the export script that is causing the problem:
(function () { var thisHypeDocument = null; function preInit() { if(EB.isInitialized()) { init(); } else { EB.addEventListener(EBG.EventName.EB_INITIALIZED, init); } } function init() { show(); } function show() { if(thisHypeDocument != null) { thisHypeDocument.showSceneNamed(thisHypeDocument.sceneNames()[0]); } } function hypeDocumentLoadCallback(hypeDocument, element, event) { thisHypeDocument = hypeDocument; if(!EB.isInitialized() ) { // don't load the Hype document until Sizmek EBLoader has loaded return false; } return true; }
if("HYPE_eventListeners" in window === false) { window.HYPE_eventListeners = Array(); } window.HYPE_eventListeners.push({"type":"HypeDocumentLoad", "callback":hypeDocumentLoadCallback}); window.addEventListener('load', preInit);
})();
It looks like it is running EB.isInitialized() is running twice, once before the HYPE file has loaded and then again afterwards causing my custom Script in HYPE to run twice.
When I usually create Sizmek ads, I write the following script manually inside of HYPE in 'On Scene Load':
function onEBReady(){
if (typeof(EB) == 'undefined') {
setTimeout(onEBReady, 10);
} else {
if (!EB.isInitialized()) {
EB.addEventListener(EBG.EventName.EB_INITIALIZED,initSizmek);
}
else {
initSizmek()
}
}
}
function initSizmek(){
// Do Something
}
onEBReady();
So I guess the Export Script Doesn't need the function preInit() { ... } part ??
If I remove the following it works:
function preInit() { if(EB.isInitialized()) { init(); } else { EB.addEventListener(EBG.EventName.EB_INITIALIZED, init); } } function init() { show(); } function show() { if(thisHypeDocument != null) { thisHypeDocument.showSceneNamed(thisHypeDocument.sceneNames()[0]); } }
My Question then, is can this be removed from the export script or is this needed in some way that I cannot see?
Thanks
Darren
Sizmek_ExportScript.hype.zip (20.5 KB)