Flash help is needed.

Discussion in 'Programming' started by exodus, May 10, 2008.

  1. #1
    I need to figure out how to capture any keypressed when the flash app has focus. I want to know how does the game developers capture the up, down, left, right, a, s, z, x keys and send them to the flash application.


    I found the following code, but it is for flash and I am using flex instead of flash and don't have frames to place it.

    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
    	trace("DOWN -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));
    };
    keyListener.onKeyUp = function() {
    	trace("UP -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));
    };
    Key.addListener(keyListener);
    Code (markup):
     
    exodus, May 10, 2008 IP
  2. coder999

    coder999 Banned

    Messages:
    727
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    coder999, May 10, 2008 IP
  3. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #3
    Yep, I seen that, but the page doesn't load for me all the way and I don't see the link to the tutorial. Post the link to where the tutorial link leads please.

    Cause you just posted the tut header not the link to the tut. ;)

    Oh yeah, this is Adobe FLEX not flash so I can't hook into any KeyFrames of movie clips because Flex doesn't have it. So there isn't any "onClipEvent(enterFrame){"... Flex is based on Flash, but doesn't have the movie clips stuff.
     
    exodus, May 10, 2008 IP