Copy link to clipboard
Copied
Hello,
I'm a web app developer and I'm working with Captivate. I'm not a captivate designer myself, just a programmer, so I don't know the first thing about Captivate (though I'm working with someone who does). I'm wonder if there's an event that fires when the captivate is done--that is, when the user clicks on the "submit" button on the last slide after which there is nothing more for the captivate to do.
My friend the Captivate designer says the submit button is wired up to an event handler in the CPM.js file. The script is named "assessment_Pass" and we've located the event handler in CPM.js. However, I can't work with this. I can't manually manipulate minimized javascript that Captivate generates, especially when we've got hundreds of captivate files and keep getting updated. I need to work in the javascript in my Visual Studios project. If I could know what event fires (if an event fires) when the captivate is done, I can then wire it up to a javascript event handler in my development environment.
I found this list of Captivate events (they're actually for the Captivate API Interface, which I'd prefer to work with, but any event will do), but none of the one's I tried seem to fire.
Any help is much appreciated.
"TLCMediaDesign" wrote:window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){
resultChanged();},"result");
This solved my problem--I had the arguments being passed in the wrong order: event, variable, handler.
But you have it as: event, handler, variable.
Once I switched it around, it started working.
Copy link to clipboard
Copied
Events are exposed only for interactive objects (buttons, button smartshapes, etc.) and ON_SLIDE_ENTER and ON_SLIDE_EXIT (the latter of which actually fires on the first frame of the *following* slide, unless it's been fixed in Cp8).
Given that info, perhaps there is an opportunity for you to create a button/smartshape event yourself or, if you want to call an event at the end of a Captivate project you could always just add a slide to the end of the project, time it to .01 seconds, and in the ON_ENTER action you could select Execute Javascript and make any calls you like.
Copy link to clipboard
Copied
Maybe if you explained what you are trying to accomplish I could point you in the right direction. Maybe you could use the CPAPI_MOVIESTOP or CPAPI_VARIABLEVALUECHANGED events and check if on the last slide.
You can also write a custom js file and include it in the published ffiles as well as have the include statement in the index.html template.
Copy link to clipboard
Copied
Why dont you use a if inside a timer and just check if that is the last slide?
if(cpInfoCurrentSlide == cpInfoSlideCount)
Copy link to clipboard
Copied
"elearning_dude" wrote:
Events are exposed only for interactive objects (buttons, button smartshapes, etc.) and ON_SLIDE_ENTER and ON_SLIDE_EXIT (the latter of which actually fires on the first frame of the *following* slide, unless it's been fixed in Cp8).
Well, it's a submit button on the captivate that's supposed to fire the event. Is that an interactive object?
"TLCMediaDesign" wrote:
Maybe if you explained what you are trying to accomplish I could point you in the right direction. Maybe you could use the CPAPI_MOVIESTOP or CPAPI_VARIABLEVALUECHANGED events and check if on the last slide.
I would like to know when the captivate ends (i.e. when the user has gone through all the slides and has clicked the submit button) and to do some processing in javascript afterwards (essentially, calculate the user's score and figure out whether they passed or failed).
I'm trying the CPAPI_VARIABLEVALUECHANGED event on a captivate variable called "result". My friend the Captivate designer says that when the user clicks the last submit button, a script is run to change the value of this variable. When it changes, this event should be fired and I should be able to catch it, no?
I'm doing it like this:
_captivateWindow.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED", "result", ResultChanged);
...
var ResultChanged = function()
{
alert("hello");
}
but I'm not getting my hello message.
I will try the timer idea that andreleal suggested and get back to you.
Copy link to clipboard
Copied
Try this
var interfaceObj;
var eventEmitterObj;
window.addEventListener("moduleReadyEvent", function(evt)
{
interfaceObj = evt.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});
function initializeEventListeners()
{
if(interfaceObj)
{
if(eventEmitterObj)
{
window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){
resultChanged();},"result");
}
}
}
function resultChanged()
{
alert("resultChanged called")
}
Copy link to clipboard
Copied
The timer idea didn't work.
I can get the current slide number with the timer event handler, but since the submit button doesn't move on to a next slide, it stays at the same slide number as it did before the submit button was clicked.
Copy link to clipboard
Copied
Is the Submit button a custom one, or is it the one that is provided by Captivate to post quiz results?
Copy link to clipboard
Copied
"TLCMediaDesign" wrote:window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){
resultChanged();},"result");
This solved my problem--I had the arguments being passed in the wrong order: event, variable, handler.
But you have it as: event, handler, variable.
Once I switched it around, it started working.
Copy link to clipboard
Copied
Great you could mark the answer as correct.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now