Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Counting variable by keypress

  1. #11
    Join Date
    Mar 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Okay i think i understand, thank you.

    MovieClip.onKeyUp = function () {
    trace ("You pressed a key");
    };
    how to i tell flash that i mean the button space?
    im not familiar with Key.getCode or Key.getAscii yet.

  2. #12
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    It's fairly straightforward. You could either of those methods within the onKeyUp (or onKeyDown) function to determine the key that is pressed.

    For example:
    Code:
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function() {
       trace("You just typed: "+Key.getCode());
    };
    Key.addListener(keyListener);
    Key.getAscii() and Key.getCode() are pretty much the same. The main difference is that Key.getAscii() respects the key's capitalization and Key.getCode() does not.

Bookmarks

Posting Permissions

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