I want to use the CPAPI_SLIDEENTER event in an external JavaScript.
The reason is that the authors on the project then don't have to deal with custom variables etc.
I have succeeded in doing want I want. Everything is ok when I preview, both as Html5 and Flash.
When I publish as:
Its seems that the moduleReadyEvent never fires when published as Flash + Scorm
The problem can be recreated by adding this code (taken from this excellent article Common JS interface) to the standard.js file:
var interfaceObj;
var eventEmitterObj;
window.addEventListener("moduleReadyEvent", function(evt)
{
console.log("moduleReadyEvent OK "); // --> never happens!!
interfaceObj = evt.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
//check if window.cpAPIInterface is available
if(interfaceObj)
{
//check if window.cpAPIEventEmitter is available
if(eventEmitterObj)
{
//add a listener to CPAPI_SLIDEENTER event
eventEmitterObj.addEventListener("CPAPI_SLIDEENTER",function(e)
{
console.log("CPAPI_SLIDEENTER\n"+JSON.stringify(e,null,"\t"));
});
eventEmitterObj.addEventListener("CPAPI_VARIABLEVALUECHANGED","cpInfoCurrentSlide",functi on(e)
{
console.log("CPAPI_VARIABLEVALUECHANGED\n"+JSON.stringify(e,null,"\t"));
});
eventEmitterObj.addEventListener("CPAPI_INTERACTIVEITEMSUBMIT",function(e)
{
console.log("CPAPI_INTERACTIVEITEMSUBMIT\n"+JSON.stringify(e,null,"\t"));
});
eventEmitterObj.addEventListener("CPAPI_SLIDEEXIT",function(e)
{
console.log("CPAPI_INTERACTIVEITEMSUBMIT\n"+JSON.stringify(e,null,"\t"));
});
}
}
});
Has anyone experienced this too? Is it a bug? Am I doing something wrong?