That means you haven't added the component as a child of some other
component on the stage (like the main app).  You have to be on the
display list in order to get keystrokes.

________________________________

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



if in my component i add this line of code

trace(systemManager) i get "null"

> public function Stage()
> {
> super();
> 
trace(systemManager);
> 
> }

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> 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:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of carlo.cavallieri
> Sent: Tuesday, March 27, 2007 1:47 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> 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