Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Key > ENTER (Key.ENTER property) | |||
public static ENTER : Number
The key code value for the Enter key (13).
Availability: ActionScript 1.0; Flash Player 5
The following example moves a movie clip called car_mc a constant distance (10) when you press an arrow key. The car_mc instance stops when you press Enter and deletes the onEnterFrame event.
var DISTANCE:Number = 5;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
switch (Key.getCode()) {
case Key.LEFT :
car_mc.onEnterFrame = function() {
this._x -= DISTANCE;
};
break;
case Key.UP :
car_mc.onEnterFrame = function() {
this._y -= DISTANCE;
};
break;
case Key.RIGHT :
car_mc.onEnterFrame = function() {
this._x += DISTANCE;
};
break;
case Key.DOWN :
car_mc.onEnterFrame = function() {
this._y += DISTANCE;
};
break;
case Key.ENTER :
delete car_mc.onEnterFrame;
break;
}
};
Key.addListener(keyListener);
When you use this example, be sure to select Control > Disable Keyboard Shortcuts in the test environment.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001756.html