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

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

Example
The following example creates a new listener object and defines a function for
The last line uses
addListener()
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
if the key specified in
true
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
- The key code value assigned to a specific key or a Key class property associated
code:Number
with a specific key.
Returns
- The value
Boolean
Example
The following script lets the user control the location of a movie clip (
car_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x += 10;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 10;
}
};
to register the listener with the Key object so that it can
is pressed;
code
if the key specified in
true
otherwise.
false
is pressed;
code
false
.
onKeyDown
otherwise.
):
car_mc
Key
381

Advertisement

Table of Contents
loading

Table of Contents