Key
389
date_txt.text = today_date.toString();
}
};
Key.addListener(keyListener);
When using this example, make sure that you select Control > Disable Keyboard Shortcuts in
the test environment.
UP (Key.UP property)
public static UP :
Number
The key code value for the Up Arrow key (38).
Availability:
ActionScript 1.0; Flash Lite 2.0
Example
The following example moves a movie clip called
car_mc
a constant distance (10) when you
press the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a
linkage identifier of
horn_id
for this example.
var DISTANCE:Number = 10;
var horn_sound:Sound = new Sound();
horn_sound.attachSound("horn_id");
var keyListener_obj:Object = new Object();
keyListener_obj.onKeyDown = function() {
switch (Key.getCode()) {
case Key.SPACE :
horn_sound.start();
break;
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);
Содержание Flash Lite 2
Страница 1: ...Flash Lite 2 x ActionScript Language Reference...
Страница 22: ...22 Contents...
Страница 244: ...244 ActionScript language elements...
Страница 760: ...760 ActionScript classes...