1 Reply Latest reply on Oct 10, 2006 8:58 AM by .:}x-=V!P=-x{:.

    Some problems about key press.

    ricky1980
      Dear All,

      I have the following codes that want to move a movie clip "car_mc", it work fine !
      But how can i modify the codes that can accept two or more keypress.
      For example if i press left key and up key at the same time, it will move the car_mc in
      x and y position respectively.


      var DISTANCE:Number = 10;
      var keyListener_obj:Object = new Object();
      keyListener_obj.onKeyDown = function() {

      switch (Key.getCode()) {

      case Key.LEFT :
      car_mc._x -= DISTANCE;
      break;
      case Key.UP :
      car_mc._y -= DISTANCE;
      break;
      case Key.RIGHT :
      car_mc._x += DISTANCE;
      break;
      case Key.DOWN :
      car_mc._y += DISTANCE;
      break;
      }
      };
      Key.addListener(keyListener_obj);


      Regards,

      Ricky