Skip to main content
Inspiring
April 19, 2018
Answered

OAM file keyboard function not working when in Captivate

  • April 19, 2018
  • 1 reply
  • 413 views

I'm working on a responsive Captivate 2017 project with breakpoints. I have created a simple animation in Adobe Animate, that has a movieclip and a button on it. When the button is pressed it plays the movieclip, but I also want this to be keyboard accessible, so I made it that when the user hits the 'g' key the movieclip will play as well.

This is what my code in animate looks like (movieclip is named 'takeOff' and button is named 'goBtn'):

this.play();

createjs.Touch.enable(stage);

this.goBtn.addEventListener("mousedown", go.bind(this));

function go(){

this.takeOff.gotoAndPlay(1);

}

window.addEventListener("keydown",keyPressed1.bind(this));

function keyPressed1(evt){

var theKey = evt.key.toLowerCase();

if(theKey=="g"){

this.takeOff.gotoAndPlay(1);

}

}

It works perfectly when I test it in Chrome. It's an HTML5 document in Animate.

When I export it as an OAM file and add it into my Captivate project, clicking the button works to run the movieclip, however pressing the G key does not. I'm wondering if it is not communicating the key event within Captivate? I'm not a coder and don't know much about this kind of stuff. Is there anyway to make it so that when the OAM is embedded in Captivate it can still listen for the key press event? Not sure why the mousedown function is still working, but the keydown is not.

Thanks!

This topic has been closed for replies.
Correct answer TLCMediaDesign

Change this line:

window.addEventListener("keydown",keyPressed1.bind(this)); 

To:

window.parent.window.addEventListener("keydown",keyPressed1.bind(this)); 

1 reply

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
April 19, 2018

Change this line:

window.addEventListener("keydown",keyPressed1.bind(this)); 

To:

window.parent.window.addEventListener("keydown",keyPressed1.bind(this)); 

KeelyMAuthor
Inspiring
April 19, 2018

Thank you!!

Known Participant
May 22, 2018

I made an OAM file like mentioned above and imported into dreamweaver. Now I get this message:

"Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame."

Is there anyway to avoid that?