EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Onkeyup (Key.onkeyup Event Listener); PGDN (Key.pgdn 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 687
onKeyUp (Key.onKeyUp event listener)
onKeyUp = function() {}
Notified when a key is released. To use onKeyUp, you must create a listener object. You can
then define a function for
onKeyUp and use addListener() to register the listener with the
Key object, as shown in the following example:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("DOWN -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey:
"+chr(Key.getAscii()));
};
keyListener.onKeyUp = function() {
trace("UP -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey:
"+chr(Key.getAscii()));
};
Key.addListener(keyListener);
Listeners enable different pieces of code to cooperate because multiple listeners can receive
notification about a single event.
A Flash application can only monitor keyboard events that occur within its focus. A Flash
application cannot detect keyboard events in another application.
Availability: ActionScript 1.0; Flash Player 6
See also
addListener (Key.addListener method)
PGDN (Key.PGDN property)
public static PGDN : Number
The key code value for the Page Down key (34).
Availability: ActionScript 1.0; Flash Player 5
Example
The following example rotates a movie clip called
car_mc when you press the Page Down or
Page Up key.
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.PGDN)) {
car_mc._rotation += 5;
} else if (Key.isDown(Key.PGUP)) {
car_mc._rotation -= 5;
}
};
Key.addListener(keyListener);

Table of Contents

Related product manuals