EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - ENTER (Key.enter Property)

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Key 677
ENTER (Key.ENTER property)
public static ENTER : Number
The key code value for the Enter key (13).
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. 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.

Table of Contents

Related product manuals