You component must implement IFocusManagerComponent if you want it to
receive focus.
 
public class Stage extends UIComponent implements IFocusManagerComponent
 
If you want to capture all keystrokes, listen to the stage.
 
systemManager.stage.addEventListener( KeyboardEvent.KEY_DOWN, onKeyDown
);

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of carlo.cavallieri
Sent: Tuesday, March 27, 2007 1:47 PM
To: [email protected]
Subject: [flexcoders] UIComponent: focus problem?



Hi,

i have a simple "Test Component" that display the key pressed by the
user, but it doesn't log anything

package
{
import flash.display.*;
import flash.events.*;
import mx.core.*;

public class Stage extends UIComponent
{

public function Stage()
{
super();

//height = 300;
//width = 400;

//
// keyboard binding
//
addEventListener( KeyboardEvent.KEY_DOWN, onKeyDown );

}

private function onKeyDown( event:KeyboardEvent ):void
{
trace("Key Code: "+event.keyCode);
}

}
}

Where i'm wrong?



 

Reply via email to