All events dispatched by objects on the displaylist flow through it.
There is a capture phase and an optional bubble phase.  Keyboard events
bubble.
 
Keyboard events are dispatched by the object that has the focus
(stage.focus).  Nobody has focus when the app starts up.
 
You can read up on events in the ASDoc, but it is largely based on the
W3C DOM Events spec http://www.w3.org/TR/DOM-Level-3-Events/events.html

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Troy Gilbert
Sent: Thursday, March 29, 2007 2:27 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Keyboard events flow through display list,
right?



AS-only projects feel very liberating as the number of unknowns (as in
parts of the Flex framework I don't understand or are poorly documented)
is decreased dramatically. The trade-off is there's no Flex framework to
do a lot of work for you! 

I'm doing a "game" though, so there's not a bunch of traditional GUI
that I need the framework to help out with. Straight AS3 is great... and
about 900k lighter than the full Flex burrito.

Oh, and thanks for reminding of the stage's focus property... for
whatever reason, it hadn't popped up in the docs when I searched for
"focus" and thus I had resigned to believing I was remember something
from the Flex framework (like an Application property). Glad to find it!


I'm still curious about my original supposition that keyboard events
flow through the display list... but I guess they flow through the
display list to the object that the stage.focus property points at...
which is probably null or the stage itself when my app starts up... 

Troy.



On 3/29/07, Paul DeCoursey <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

        I don't really know and I haven't tried it but, set the 
        focus property on the stage to the sprite you want to have
focus. I
        think that this will give keyboard focus to the sprite.
        
        I've been considering doing Actionscript only project for a few
        experiments but I haven't jumped in yet. I'm curious to how well
your
        experience has gone.
        
        paul
        
        --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "thirtyfivemph"
<[EMAIL PROTECTED]> 
        wrote:
        >
        > I've created an ActionScript Project, so no UIComponent
controlling
        focus.
        > 
        > I've got the root of my app, a sprite, it has a child sprite
and a
        > grandchild sprite.
        > 
        > I was under the impression (nee, utter certainty) that I could
stick a
        > "addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown)" in my
grandchild
        > sprite and it would get the event (passed down the display
list).
        > Well, it doesn't...
        > 
        > So, I tried a few things, and even my top-level sprite (the
one
        > directly parented to the stage) doesn't get keyboard events.
Only if I
        > add my event listener to the *stage* do I get keyboard events.
        > 
        > Am I wrong that keyboard events flow through the display list
(like
        > mouse events or ENTER_FRAME)?
        > 
        > I guess it would depend on who had the focus, but how is that
        > controlled in an AS project with all sprites? And wouldn't my
        > top-level sprite get the focus when the app launches?
        > 
        > The docs are all focused on Flex, so it's tough to get an
answer to
        > this in a world without the FocusManager! ;-)
        > 
        > Troy.
        >
        
        

        


 

Reply via email to