Skip to main content
Participating Frequently
January 29, 2018
Question

Executing advanced action using Javascript in Animate CC

  • January 29, 2018
  • 2 replies
  • 745 views

I'm trying to execute an advanced action in Captivate when a button created in Animate CC is click.

I've been following this tutorial: How to Trigger Captivate Advanced Actions with Javascript | eLearning

I've created a clickbox called "Menu_btn" which on click executes an advanced action.

My code in Animate CC is:

this.menu_mc.addEventListener("click", fl_MouseClickHandler.bind(this));

function fl_MouseClickHandler()

{

    this.menu_mc.gotoAndPlay('click');

    window.parent.cp.clickHandler(Menu_btn);

}

The "window.parent.cp.clickHandler(Menu_btn);" should execute the advanced action as if the "Menu_btn" clickbox was clicked, but nothing happens.  If I create another button in captivate with the execute JavaScript code "cp.clickHandler(Menu_btn);" it works fine, so I'm not sure why it isn't working in Animate CC. I've replaced the "window.parent.cp.clickHandler(Menu_btn);" with "window.parent.cp.hide("SmartShape_666");" just to check the function was firing and that worked fine.

Has anyone had any look getting the cp.clickHandler() function to work outside of Captivate?

This topic has been closed for replies.

2 replies

Participant
July 13, 2018

I had this same issue when using "clickHandler", trying to trigger a button click in Captivate from a separate Captivate window. "window.opener.cp.HIde(my_button)" works but not "window.opener.cp.clickHandler(my_button)", comes back as undefined.

So I tried "window.opener.cp.clickHandler(window.opener.my_button)" and that worked.

Participating Frequently
January 30, 2018

I've also tried "window.cp.runJavascript(cp.model.data.Menu_btn.oca);" and "window.parent.window.cp.runJavascript(cp.model.data.Menu_btn.oca);" but still no luck.

craigs8411935
Participating Frequently
February 12, 2018

Hi Josh I am trying to get this to work also, Javascript in captivate the suggestion I had was not successful, I have tried the following

var box = $('#restart_loop')[0]; cp.clickHandler(box); inside captivate on page load or another button and this fires perfectly. but i too wanted to do this same function from animate cc on an .oam button

I have tried the following lines

this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

     function fl_MouseClickHandler()

     {

     var box = $(window.parent().'#restart_loop')[0];

     window.parent.cpAPIInterface(box)

      }

or

this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

     function fl_MouseClickHandler()

     {

window.parent.cp.clickHandler("restart_loop");

}

or

this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

     function fl_MouseClickHandler()

     {

window.parent.cp.clickHandler(box("restart_loop"));

}

None have worked

have you had any success?