Skip to main content
Participating Frequently
Jan 29, 2018 4:45 PM UTC
Question

Executing advanced action using Javascript in Animate CC

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 is closed to new replies. Start a new post to keep the conversation going.

3 replies

Participant
Jul 13, 2018 6:57 PM UTC

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.

Translate
Participating Frequently
Jan 30, 2018 9:51 AM UTC

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.

Translate
craigs8411935
Participating Frequently
Feb 12, 2018 9:58 AM UTC

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?

Translate