Key.UP
Availability
Flash Player 5.
Usage
Key.UP:Number
Description
Property; constant associated with the key code value for the Up Arrow key (38).
Example
The following example moves a movie clip called
the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage
identifier of
horn_id
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);
370
Chapter 2: ActionScript Language Reference
for this example.
a constant distance (10) when you press
car_mc
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers