dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Keyboard control

  1. #1
    Senior Member
    Join Date
    Dec 2000
    Posts
    147

    Keyboard control

    How can i make a combination of keys make a movie clip visible? Basically i want something like this to work:

    if(Key.isDown(Key.Alt && Key.A)){
    reminder._visible = true;
    }

    So when someone presses the Alt and A keys down at the same time the 'reminder' mc becomes visible?

    Doesnt have to be these keys if thats an issue.
    mileso

  2. #2
    Senior Member
    Join Date
    Oct 2008
    Posts
    227
    Hi! Most of the keys have a code, instead of the actual character.
    "A" for example, is 65. More keycodes can be found here: http://www.video-animation.com/flash8_024.shtml

    Code:
    var keyListener:Object = new Object();
    keyListener.onKeyDown = function(){
    if(Key.isDown(Key.ALT) && Key.isDown(65)){
    reminder._visible = true;
    }
    }
    Key.addListener(keyListener);
    This script only checks when a button is down, instead of using onEnterFrame, which constantly checks for it and uses more CPU.
    NOTE: The ALT key won't work while testing in Flash.
    Last edited by Vexy; 08-11-2009 at 08:49 PM.

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    147
    Sorted, cheers!
    mileso

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