Onkeyup (Button.onkeyup Handler) - 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
In the following example, a function that sends text to the Output panel is defined for the
handler. Create a button called
onKeyDown
ActionScript in a frame on the Timeline:
my_btn.onKeyDown = function() {
trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")");
};
function getKeyPressed():String {
var theKey:String;
switch (Key.getAscii()) {
case Key.BACKSPACE :
theKey = "BACKSPACE";
break;
case Key.SPACE :
theKey = "SPACE";
break;
default :
theKey = chr(Key.getAscii());
}
return theKey;
}
Select Control > Test Movie to test the SWF file. Make sure you select Control > Disable
Keyboard Shortcuts in the test environment. Then press the Tab key until the button has
focus (a yellow rectangle appears around the
keyboard. When you press keys, they are displayed in the Output panel.
See also

onKeyUp (Button.onKeyUp handler)

(Key.getCode method)
onKeyUp (Button.onKeyUp handler)
onKeyUp = function() {}
Invoked when a button has input focus and a key is released. The
invoked with no parameters. You can use the
to determine which key was pressed.
Availability: ActionScript 1.0; Flash Lite 2.0
on the Stage, and enter the following
my_btn
instance) and start pressing keys on your
my_btn
,
getAscii (Key.getAscii method)
Key.getAscii()
,
getCode
event handler is
onKeyUp
and
Key.getCode()
Button
methods
281

Advertisement

Table of Contents
loading

Table of Contents