Flash Lite 2 |
|||
| Flash Lite 2.x ActionScript リファレンスガイド > ActionScript クラス > Key > isDown (Key.isDown メソッド) | |||
public static isDown(code: Number) : Boolean
code で指定されたキーが押された場合は true、それ以外の場合は false を返します。
使用できるバージョン : ActionScript 1.0、Flash Lite 2.0
code: Number - 特定のキーに割り当てられたキーコード値、または特定のキーに関連付けられた Key クラスプロパティ。
Boolean - code で指定されたキーが押された場合は true、それ以外の場合は false。
次のスクリプトは、ユーザーがムービークリップ car_mc の位置を制御できるようにします。
car_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x += 10;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 10;
}
};