EasyManua.ls Logo

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE - Isdown (Key.isdown Method)

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE
780 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 381
Example
The following example creates a new listener object and defines a function for
onKeyDown.
The last line uses
addListener() to register the listener with the Key object so that it can
receive notification from the key down event and display information in the Output panel.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.INSERT)) {
trace("You pressed the Insert key.");
}
};
Key.addListener(keyListener);
isDown (Key.isDown method)
public static isDown(code:Number) : Boolean
Returns true if the key specified in code is pressed; false otherwise.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
code:Number - The key code value assigned to a specific key or a Key class property associated
with a specific key.
Returns
Boolean - The value true if the key specified in code is pressed; false otherwise.
Example
The following script lets the user control the location of a movie clip (
car_mc):
car_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x += 10;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 10;
}
};

Table of Contents

Related product manuals