I am sure this is old news to many of you, but today was the first time I have run into this issue. I am working on a site for a client that has very high accessibility requirements. I originally built my project to be controlled using the mouse and was asked this morning to add the ability to navigate it using the arrow keys of the keyboard. It only took me a couple minutes to get this functionality working in Flash, but when I tested it using Firefox I was not getting any response from the keyboard. I tried it out in IE7 and everything worked like a charm. After a couple minutes of searching I came across this site and found my solution. Apparently Firefox always returns the Key.isDown() function as false if you have wmode=”transparent” or wmode=”opaque” in your html object and embed tags, but if you use Key.getCode() everything works perfect.
Here is a snippet of code showing the workaround to this issue:
function reset():Void {
var next:Boolean = false;
var prev:Boolean = false;
var keyboardListener:Object = new Object();
keyboardListener.onKeyDown = function () {
if (Key.getCode() == 39) next = true;
if (Key.getCode() == 37) prev = true;
}
this.onEnterFrame = function() {
if (next) {
delete this.onEnterFrame;
trace("next page");
flash.external.ExternalInterface.call("alert",
"next page");
reset();
}
if (prev) {
delete this.onEnterFrame;
trace("previous page");
flash.external.ExternalInterface.call("alert",
"previous page");
reset();
}
}
Key.addListener(keyboardListener);
}
reset();
I added some JavaScript Alerts to prove it works in the browser.
Hey Fraser,
I ran into other issues with wmode=transparent and blogged about it awhile ago.
http://blog.scottgmorgan.com/php/default.php?topicID=170&contentID=739&rowID=114
I also ran into issue triggering mouse events, and componetns like the combo box and the datagrid just died.
Lastly, I experienced huge performance hits using wmode=transparent. And running an onEnterFrame on top of a spiking app isnt good. You may want to switch that to an interval, lower the impact a bit or better yet probably best to stay away from wmode=transparent it if at all possible.