Try adding a second listener in capture phase.
private function stageListener(event:Event):void {
// stage.focus = this;
stage.addEventListener(KeyboardEvent.KEY_DOWN, this.pressed);
stage.addEventListener(KeyboardEvent.KEY_DOWN, this.pressed, true);
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of cougar_shuttle
Sent: Thursday, January 24, 2008 8:52 PM
To: [email protected]
Subject: [flexcoders] keyboard ocus within actionscript module
I am subclassing mx.modules.Module and I can listen to keyboard events
if I stage.focus = this; in the Event.ADDED_TO_STAGE handler but I
can't figure out how to always receive keyboard events.
at the end of the constructor...
addEventListener(Event.ADDED_TO_STAGE, stageListener);
}
private function stageListener(event:Event):void {
// stage.focus = this;
stage.addEventListener(KeyboardEvent.KEY_DOWN, this.pressed);
...
pressed() is not getting called unless I uncomment stage.focus = this;
How do I trap keyboard events all the time?