The example in the documentation at
http://livedocs.adobe.com/flex/3/html/help.html?content=events_11.html has
the event listener for the keyDown event being attached to the application
to achieve the behavior you're looking for. I'd guess that the reason the
code you sent doesn't work is because the event listener is attached to an
empty form, there's nothing there for the user to send a keypress to. Maybe
adding a text input in the form would work, you may still have to attach the
listener to the actual element (the text field).

--
Howard Fore, [email protected]
"The universe tends toward maximum irony. Don't push it." - Jeff Atwood


On Sat, Apr 18, 2009 at 10:12 PM, Laurence MacNeill
<[email protected]>wrote:

> At 09:26 PM 4/18/2009, you wrote:
>
>> On Sat, Apr 18, 2009 at 9:12 PM, Laurence MacNeill <<mailto:
>> [email protected]>[email protected]> wrote:
>> Being a total flex-newb, I have no idea how to do that.  :-)  I do
>> understand the concept of what you said, but I have no idea how to implement
>> that into real code.
>>
>> Do you think you could give me a snippet of code that will show a button
>> and the event listener?  Or point me somewhere on the Internet.
>>
>>
>> <http://www.google.com/search?q=flex+button+event+listener>
>> http://www.google.com/search?q=flex+button+event+listener is a good place
>> to start. Google is your friend.
>>
>> You might also try <
>> http://www.adobe.com/devnet/flex/quickstart/handling_events/>
>> http://www.adobe.com/devnet/flex/quickstart/handling_events/
>>
>> There's a lot of code on the Adobe website for getting you started in
>> Flex. I highly recommend that you try the "Flex in a week" (<
>> http://www.adobe.com/devnet/flex/videotraining/>
>> http://www.adobe.com/devnet/flex/videotraining/).
>>
>>
>>
> Ok, I've written the following.  It should pop up an Alert window when you
> press a key.  But it doesn't.  Why?
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute">
>
>  <mx:Script>
>    <![CDATA[
>      import mx.controls.Alert;
>      import flash.events.KeyboardEvent;
>
>      private function keyHandler(event:Event):void {
>        Alert.show ("You pressed a key");
>      }
>
>    ]]>
>  </mx:Script>
>
>  <mx:Form x="10" y="10" width="100%" height="100%"
> keyDown="keyHandler(event)"/>
>
> </mx:Application>
>
>
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in
> the subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>

Reply via email to