Copy link to clipboard
Copied
Hi
It is silly but I am afraid I cannot get the answer to a very basic question...
How would I populate the Current frame value when I use this line in the OnEnter action?
window.cpAPIInterface.getCurrentFrame();
I can populate the text "Text for the variable" in a TEB with the variable "varMyvariable" with this line.
window.cpAPIInterface.setVariableValue("varMyvariable","Text for the variable.");
but I am missing something very basic here ...
Thank you in advance
B
1) OnEnter Action:- Execute javascript
var vframe = window.cpAPIInterface.getCurrentFrame();
2) On captivate slide to show the variable value:-
$$vframe$$
3) create vframe variable in captivate variable also.
Copy link to clipboard
Copied
Hi You are calling a function in the OnEnter action which will return currentFrame value but to show the value on screen you have to assign that function to a variable and then use on captivate stage $$variablevaluename$$.
Copy link to clipboard
Copied
1) OnEnter Action:- Execute javascript
var vframe = window.cpAPIInterface.getCurrentFrame();
2) On captivate slide to show the variable value:-
$$vframe$$
3) create vframe variable in captivate variable also.
Copy link to clipboard
Copied
Thank you so much. I was trying different options and at the end it just turns out that I lack understanding of the fact that the line is a function and should be assigned to the variable. That's great.
I am trying to understand the difference between the window.cpAPIInterface and window.cpAPIEventEmitter.
I am reading the Adobe explanation but would you be so kind to help me with that case plase?
I assign this line OnEnter
window. cpAPIEventEmitter. addEventListener("CPAPI_SLIDEENTER", function(){alert("Slide Entered");});
I get the alert window alright, but the timeline continues. How can I make so that the alert stops the timeline and the timeline continues only when the user has clicked OK.
As to the stop, I can untick the box Continue playing. But how to make it so when clicking on the OK button of the alert, the playhead is released?
I promise this is my last question . Thank you for your help
B
Copy link to clipboard
Copied
You're not going to have control as to whether the OK button is clicked on an Alert() box. Well, there are ways but they are not cross browser compatible.
You could use a Confirm box that returns a Boolean value depending on whether OK was clicked, or if Cancel was clicked. Theoretically, you could do the same action for either button. Something like this:
window. cpAPIEventEmitter. addEventListener("CPAPI_SLIDEENTER", yourFunction());
function yourFunction() {
cpCmndPause = 1;
if (confirm("Your message here.")) {
// your code if OK is clicked.
} else {
// your code if Cancel was clicked
}
}
Make sure you have "Continue playing...." checked and when the user clicks OK or Cancel, the timeline will play after the box is closed.
Copy link to clipboard
Copied
That is a very nifty solution. I have a few questions on the details
1. Where do I change "Message from webpage" text?
2. How do I adjust where on the screen the Confirm box would appear?
3. I see that I can also use a prompt but also not a solution. Confirm method is interesting but what if I just want them to have one button. It would be just a message they must accept.
Thanks again!
B
PS: What is wrong in my conditions?
window.cpAPIEventEmitter. addEventListener("CPAPI_SLIDEENTER", yourFunction());
function yourFunction() {
cpCmndPause = 1;
if (confirm("You are about to enter the realm.")) {
cpCmndGotoSlide = 3;
} else {
cpCmndGotoSlide = 4;
}
}
Copy link to clipboard
Copied
Unfortunately, you're not going to have much control over anything in a browser initiated dialog box. Placement, the buttons, and what the default text says are handled behind the scenes.
The conditions you have are fine, it isn't working because I noticed that the code I wrote breaks CPM.js.
I don't know how many of these you have to create, but you could always use advanced actions on slide enter to accomplish the same results very easily.
Copy link to clipboard
Copied
Thank you for your kind reply.
I understand what you mean.
What about the if and else conditions? They do not work when I use the code OnEnter.
At least are they correct?
Copy link to clipboard
Copied
The conditions are okay. They don't work because of the problem that I mentioned with CPM.js.
Copy link to clipboard
Copied
Thanks for your help.