Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-06-2008, 10:54 PM   PM User | #1
Chantcd_com
New to the CF scene

 
Join Date: Sep 2005
Location: Schertz, TX
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Chantcd_com is an unknown quantity at this point
How to read keyboard input?

(I just found this sub-forum...sorry about posting it in the main Flash/Actionscript forum...)

My program starts out this way:


Code:
    public class MyProgram extends UIComponent 
{
...

Now I heard that any UIComponent registers keyDownHandler automatically, so you just need to override that function.

But although I get no errors, there is NO sign of life as far as keyboard input goes. I programmed the keys to do some drastic things (not shown below) but nothing ever happened. So I'm wondering what I'm doing wrong.

Code:
		override protected function keyDownHandler(e:KeyboardEvent):void {
		        if (e.keyCode == Keyboard.LEFT) {
		              trace("LEFT");
		        }
		        if (e.keyCode == Keyboard.UP) {
		              trace("UP");
		        }
		        if (e.keyCode == Keyboard.DOWN) {
		              trace("DOWN");
		        }
		        if (e.keyCode == Keyboard.RIGHT) {
		              trace("RIGHT");
		        }
		        
		}
Any help would be much appreciated.

Thanks,

Matthew
Chantcd_com is offline   Reply With Quote
Old 08-08-2008, 05:10 PM   PM User | #2
Forsaken
New Coder

 
Join Date: May 2006
Location: California
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Forsaken is an unknown quantity at this point
I'm not 100% sure but I've had the same problem, by default I think what the problem is unless you've used your mouse to click on that object that object won't detect the keyboard events. I noticed this when I first used a tilelist, then I noticed this when using a circle shape in AS3.
Forsaken is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:53 AM.


Advertisement
Log in to turn off these ads.