Awesome. That did the trick.(setting stage.focus)
Thanks for the help.

Off the top of your head do you know any component in the Flex SDK that uses
this aprroach, (basically composite a Sprite that contains the core
functionality). This is so I can look at the source to study how its done ?

Thanks,
- superabe



On 2/14/07, Alex Harui <[EMAIL PROTECTED]> wrote:

   You can proxy or MyComp's setFocus can simply assign stage.focus to the
Sprite.  Which ever thing actually has stage.focus is going to be sent the
key events and that's where you need to be listening.



-Alex


 ------------------------------

*From:* [email protected] [mailto:flexcompone
[EMAIL PROTECTED] *On Behalf Of *superabe superabe
*Sent:* Wednesday, February 14, 2007 11:24 AM
*To:* [email protected]
*Subject:* Re: [flexcomponents] Keyboard events for a custom component



Thanks Alex. That makes sense.
Making some progress now.
Implementing the IFocusManagerComponent allows MyComp to fire keyDown
events.

But the child "MySprite" still does not receive keyboard events.
Do I need to proxy keyboard events down to MySprite from MyComp, or is
there a cleaner way to have the child receive Keyboard events.

TIA

- superabe

 On 2/14/07, *Alex Harui* <[EMAIL PROTECTED]> wrote:

In order to receive keyboard events, you have to have focus.  In order to
get focus in Flex, you have to implement IFocusManagerComponent.



HTH,

-Alex


 ------------------------------

*From:* [email protected] [mailto:flexcompone
[EMAIL PROTECTED] *On Behalf Of *superabe superabe
*Sent:* Wednesday, February 14, 2007 6:00 AM
*To:* [email protected]
*Subject:* [flexcomponents] Keyboard events for a custom component



I am trying to create a custom component which is an AS3 class "MyComp"
extending of UIComponent.
MyComp composites (using addChild) another class "MySprite" that extends
of Sprite.
MySprite is a  listener for Keyboard events and handles several key
presses.

The problem I see is that, when MySprite is used within MyComp, it fails
to receive any Keyboard events.
I tried listening for the "keyDown" event on MyComp itself, but that fails
to fire too.

What is the recommended approach for enabling keyboard events in custom
componnets that extend UIComponent.

Thanks,
- superabe



Reply via email to