Skip to main content
KostyaPl
Participating Frequently
December 20, 2017
Question

Execute advanced action within JavaScript

  • December 20, 2017
  • 2 replies
  • 2536 views

Hello everyone,

I am storing LevelProgress variable at localStorage and I want to execute different Advanced Actions based on values of LevelProgress.

However nowhere in documentation I can find how to execute Advanced Action with JavaScript.

Have anyone tried to do that?

I'd like to achieve this without creating extra buttons/click boxes/objects is possible. Purely triggering JavaScript on Slide enter.

Thank you.

This topic has been closed for replies.

2 replies

Inspiring
December 28, 2017

I started out looking at everything from the point of view of a programming language - wanted to be able to call everything from JS, but Captivate isn't really set up that way. I'm now combining clickboxes into slides to handle decisions that are common to several buttons/dragdrop events, etc, and that can call other JS snippets if needed. It does break up the code somewhat, but it's easier in the long run than trying to force programming concepts onto the Captivate AA model.

Shared actions can be good, too, but beware of changes as a project develops. Shared actions can't be modified once saved and in use. I find it easier to duplicate actions in most cases instead, although it makes for a much longer list.

Lilybiri
Legend
December 28, 2017

Success, but I had to debug several projects with many duplicated advanced actions that caused choking. Shared actions did solve that in an easy way.  Even when you have to edit a shared action, it takes me less time to switch the shared actions than to edit all those duplicate advanced actions. It is all about the workflow, I embraced shared actions from the beginning and learned how to use them. It needs also a different preparation but that just my personal opinion. I try to avoid duplicate advanced actions as much as possible.

Lilybiri
Legend
December 20, 2017

Slide enter can trigger an advanced/shared action as well, no need for a button event at all. I would retrieve the value from LS and use an advanced action.  I will leave you to the JS experts.

KostyaPl
KostyaPlAuthor
Participating Frequently
December 20, 2017

Hey Lilybiri,
Thank you for such swift reply.

Yes, it is indeed easy to trigger Advanced Action on Slide enter.
The reason why I've mentioned triggering JavaScript without extra objects is because I've seen several solutions here on forums and Adobe's eLearning Blog:
Re: Call advance action on variable change

How to Trigger Captivate Advanced Actions with Javascript | eLearning

However I hope that maybe there is an easier way for my particular case.

If there is still no other way I am afraid I'll have to create several dummy click boxes as I have several Advanced Actions (at least 8 at the moment).

Which makes solution far from elegant.


Thanks

Lilybiri
Legend
December 20, 2017

You can combine quite a lot of commands in different decisions in one advanced action. Are you sure you need so many different actions? I will not discuss the value of JS to extend CP-s functinoality. It may be just my personal suspicion, that I often see JS exsperts doing everything with JS, even if it would be easier with advanced/shared actions (which will be converted to JS on runtime). Since for most clients it is much easier to manage/edit advanced actions than to plunge into JS (probably in an external JS file for convenience) I stick with advanced actions and the CpExtra widget whenever possible. For work flows that are impossible with CP, like randomization, arrays, formatting numbers I will switch to JS.

Beware: I do respect the wonderful JS experts a lot, several are helping on this forum to share their expertise. In my professional life I had to use too many programming languages, happy now to take it easy with CP's advanced actions. Too lazy...

BTW CpExtra is te most wonderful widget I ever used. It is not free, but one of the features is to call an advanced action from in another advanced action.