A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: key allocations inActionscript

  1. #1

    key allocations inActionscript

    HI folks,
    A query.. I have the following piece of action scripting i want to change.

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.s)) {
    this._x -= speed;
    }
    if (Key.isDown(Key.Down)) {
    this._x += speed;
    }
    }

    At present the left and right arrow move an object left or right.
    I want to allocate a pair of buttons ie "s" for left "d" for right instead of the arrow buttons. I tried a few things but no joy.
    Please help

    Thanks
    Dave

  2. #2
    Senior Member of Toon Army lucky-black-cat's Avatar
    Join Date
    Aug 2002
    Location
    Benarraba Andalucia Spain
    Posts
    303
    Hi

    Instead of Key.s put 83 ASCII code for S, d is 68

    Code:
    onClipEvent(enterFrame){
       if (Key.isDown(83)){
          this._x -= speed;
       }
       if (Key.isDown(68)){
          this._x += speed;
       }
    }
    Hope this helps.
    http://www.property-in-the-sun.com
    Cheap Holidays in Andalucia Spain for Flash Programmers from 2005!

  3. #3
    Senior Member
    Join Date
    Nov 2000
    Location
    Jerusalem, Isreal
    Posts
    254

    try this...

    in the code

    onClipEvent (enterFrame) {
    if (Key.isDown(115)) {
    this._x -= speed;
    }
    if (Key.isDown(Key.Down)) {
    this._x += speed;
    }
    }

    this is for small "s" not for "S".
    good luck
    Matti Bar-Zeev,
    scriptaholic.

  4. #4
    Senior Member of Toon Army lucky-black-cat's Avatar
    Join Date
    Aug 2002
    Location
    Benarraba Andalucia Spain
    Posts
    303
    Hi

    I'm using a PC and a test with Key.getCode() for D/d returns 68 whether Caps Lock is on or off. A test for S/s returns 83 whether Caps Lock is on or off.

    However a test with Key.getAscii() does return the different values ie 83/115.

    Key.isDown(115) will always return FALSE as Key.isDown behaves like Key.getCode().


    So ..... you shoud use 68 and 83 and NOT 115

    Hope this clears any confusion created.
    http://www.property-in-the-sun.com
    Cheap Holidays in Andalucia Spain for Flash Programmers from 2005!

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