A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Return of the Key class to AS3

  1. #1
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506

    Return of the Key class to AS3

    I got bored over the weekend so I wrote this

    You set it up like this:

    Code:
    import Key;
    Key.listen(stage);
    Now place it in your game loop and use it the same way you did before:

    Code:
    if (Key.isDown(Key.LEFT)){trace("Left cursor key is being pressed")}
    From my new blog, but no-one's reading it yet, so I thought I'd post here as well. Enjoy.

  2. #2
    Developer
    Join Date
    Apr 2007
    Location
    UK
    Posts
    324
    Hi,

    Useful class (even though it has been done before). Nice work. I've added you to my RSS feed aggregator. I expect high quality posts sir!
    now known as dVyper

  3. #3
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405
    Nice little class. Been thinking about making something like that for weeks. I blame my laziness. But now I don't have too. My life lesson is if you hold out long enough someone will do it for you. Thanks a bunch.
    World Arcade | Facebook | Twitter - Follow MEEEE! or not......

  4. #4
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Nice work mate, and a good start to the blog.

    I'll add your link in to ours sometime tonight ( I normally screw it up so I need to build up to 30mins swearing at something which should be easy ).

    Squize.

  5. #5
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    Hi Cortana, you too sir.

    Yes that's pretty similar to what I had originally planned, but I wanted the syntax to be identical, and the class to be static, so you don't need to declare or create an instance, just import and activate it by giving it a stage ref.

    It looks great in the IDE because "Key" is still highlighted, even if you've selected publish to AS3.

    .hooligan - We're all standing on the shoulders of giants mate, just as long as you put it to good use.

    Squize - lovely, thanks! Using blogger is forcing me to do things with html/css. It reduces me to tears whenever I try and change something.

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Maybe you could add way to stop listening, way to know if it is currently working and some errors in case it goes wrong.

  7. #7
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    Good suggestions. Key 2.0 will include those features.

    I'm also thinking of a keylogger to replay games with and to submit with highscores for game verification (they were features we were going to implement in my last proect but didn't get time)

  8. #8
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Quote Originally Posted by Cortana
    Hi,

    Useful class (even though it has been done before).
    And before but cool anyway

  9. #9
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    I really should google these things before I put all the hard work in.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center