Skip to main content
Known Participant
October 31, 2018
Answered

How to Execute javascript in Specific Frame of the Timeline?

  • October 31, 2018
  • 3 replies
  • 4282 views

It was my reason to leave "Articulate Storyline" and buy "Adobe Captivate" but Adobe as always disappointed me again ... Because I can't find a way to do this :

I have a blank slide in adobe captivate 2019, Just a Blank Slide... Ok ... Now the question is: How can I execute a javascript code at frame "90" for example ...

I want to tell to timeline to execute a javascript code at frame 90 ...

Any Idea is Extremely appreciated.

This topic has been closed for replies.
Correct answer Gaanf

Thank you Gaanf....

But Still, it doesn't work...

I've done every step as you said...

I Attached my captivate file here:

https://we.tl/t-m5VkppkUdi


Can't test your project as I'm sitting behind company firewalls, blocking downloads such as your project file.

However, I noticed I had a little typo up there. Sorry for that. It's actually:

window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){cp.clickHandler(yourInterativeObject);},"cpInfoCurrentFrame");

...without [Space] between 'click' and 'Handler'. That might have been it. Sure works for me.

3 replies

Known Participant
October 31, 2018

@Gaanf Thank you for your Completely Correct Answer...

Adobe Should be Thankful for creative experts like you that solve problems of their software they never even think of...

TLCMediaDesign
Inspiring
October 31, 2018

It would be much simpler to just execute the JavaScript in the function of the event listener. You don't need a button or an advanced action:

window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){

if(window.cpInfoCurrentFrame === 90 )

{

//execute your script here.

}

},"cpInfoCurrentFrame");

or just use a setTimeout on slide enter:

setTimeout( function(){ your code here };, 3000);

Known Participant
October 31, 2018

Wow...Thanks, I Think I'll Use your Code...It's a lot simpler...

Known Participant
October 31, 2018

Dear Lilybiri and Gaanf... Thank you for your comments. I know there is no way to do such thing using Captivate alone, except using JS.and I'll wait for a JS expert.

Something that I don't know and I can't understand is, why in 2018, there is no Multimedia Authoring Program on Earth that can handle Cue points or Bookmarks in the right way ... More than one thousand engineers at Adobe worked on a program that can not do something interactive in a specific time of a movie... Captivate and Storyline seems to be more likely a video editing tool not Authoring tools ...

Inspiring
October 31, 2018

As far as I remember from having toyed around with Storyline during a 30 Days Trial Period some time ago, Storyline was perfectly able to fire an action from cue points in the timeline.

Anyway, Captivate doesn't do this through UI, but as indicated above there's still a way by utilizing the Captivate JavaScript API:

  • Create an Advanced Action like the one shown below. 'Your Action here' is whatever you want to happen on Frame 90 (sticking to your example).

  • Create an interactive object somewhere on the slide (Button, ButtonShape, ClickBox), give it a meaningful name, hide it from the output (so your learner doesn't see it/ click it), and assign your Advanced Action to it .
  • Run the following line of code from the JavaScript Script Window on Slide Enter of the slide where you want the timeline to trigger the action (make sure, 'Current' is selected in the DropDown):

    window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){cp.clickHandler(yourInerativeObject);},"cpInfoCurrentFrame");

    ..., replacing 'yourInteractivObject' with the name of the hidden object you created.
Known Participant
October 31, 2018

Thank you Gaanf....

But Still, it doesn't work...

I've done every step as you said...

I Attached my captivate file here:

https://we.tl/t-m5VkppkUdi

Lilybiri
Brainiac
October 31, 2018

I am not a JS expert, but this is perfectly possible with Advanced or Shared actions which are converted to JS on runtime, so it iwould be easy with JS as well.  You can use the system variable cpQuizInfoCurrentFrame.  There is a command 'Delay next actions by....'. which I use if I trigger an action with the On Enter event of a slide.

There are several JS experts around here, but most of them still asleep I suspect.

Inspiring
October 31, 2018

Hi Lilybiri,

I'd be curious to learn how you would do this with Advanced or Shared Actions only, since there is no event to trigger them at frame 90. 'Delay next action by...' on Slide Enter is not really the same, because it would fire no matter what, even if the slide had been paused between Slide Enter and Frame 90 or some navigation in between skipped frame 90 altogether.

I thought the only way would be to setup an event listener via cpAPIEventEmitter and have it listen to cpInfoCurrentFrame variable.

Lilybiri
Brainiac
October 31, 2018

That is true, I didn't explain the whole workflow and I am well aware of the fact that Delay next actions has its limitations like the ones you point out.  I told the OP to wait for a JS expert, didn't try to explain all my tricks since he/she clearly wants to use JS. I pointed at the firtst place to the system variable as you could read. There used to be a SWF widget by Jim Leichliter which did allow to fire an action based on an exact time on the slide in the past. This is clearly a JS use case now.