690
ActionScript classes
SHIFT (Key.SHIFT property)
public static SHIFT : Number
The key code value for the Shift key (16).
Availability:
ActionScript 1.0; Flash Player 5
Example
The following example scales
car_mc
when you press Shift.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.SHIFT)) {
car_mc._xscale = 2;
car_mc._yscale = 2;
} else if (Key.isDown(Key.CONTROL)) {
car_mc._xscale /= 2;
car_mc._yscale /= 2;
}
};
Key.addListener(keyListener);
SPACE (Key.SPACE property)
public static SPACE : Number
The key code value for the Spacebar (32).
Availability:
ActionScript 1.0; Flash Player 5
Example
The following example moves a movie clip called
car_mc
a constant distance (10) when you
press an arrow key. A sound plays when you press the Spacebar. For this example, 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;
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...