I'm not sure what to think about this one. For me it looks like a bug, but maybe there's an explanation out there. Here's the deal: if you set up the
focusRect property to null/false (or
stageFocusRect for that matter) the MouseEvent.CLICK event will
not be triggered by the keyboard. Yes, that's right, I mean by the keyboard. This is the scenario:
You have an interface with buttons that are accessible via TAB + ENTER and you assign actions as usual using the click event:
[code lang="actionscript"]button.addEventListener(MouseEvent.CLICK,callback);[/code]
If you TAB and ENTER when the button has the focus it works as expected, the event is triggered. Now, the moment you set up focusRect to null, it stops working. You can TAB to the element but when you hit enter nothing happens.
This is what I'm doing to bypass this limitation:
[code lang="actionscript"]button.addEventListener(KeyboardEvent.KEY_DOWN,callback);
private function callback(e:KeyboardEvent):void{
if(e.keyCode != Keyboard.ENTER){ return; } // if it's not enter skip actions
// do your stuff
}[/code]
But I'm getting away with it because my interface only needs to be accessible with the keyboard, no mouse. Should I have to react to both, I'd have to subscribe to both events with different callbacks and call a third function to do the work. Not nice.
By the way, using the FocusManager class is not an option because it belongs to the fl.* package that comes with the Flash IDE only whereas I'm compiling using the Flex SDK.
I hope I'm missing something here.
PS: Somebody,
anybody, please, kill MySpace. Forever.