Onkillfocus (Button.onkillfocus Handler) - MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

Example
In the following example, a function that sends text to the Output panel is defined for the
onKeyDown handler
ActionScript in a frame on the Timeline:
my_btn.onKeyDown = function() {
trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")");
};
my_btn.onKeyUp = function() {
trace("onKeyUp: "+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;
}
Press Control+Enter 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
When you press keys, they are displayed in the Output panel.
See also
onKeyDown (Button.onKeyDown handler)
(Key.getCode method)

onKillFocus (Button.onKillFocus handler)

onKillFocus = function(newFocus:Object) {}
Invoked when a button loses keyboard focus. The
parameter,
newFocus
object receives the focus,
Availability: ActionScript 1.0; Flash Lite 2.0
282
ActionScript classes
. Create a button called
instance) and start pressing keys on your keyboard.
my_btn
, which is an object representing the new object receiving the focus. If no
contains the value
newFocus
on the Stage, and enter the following
my_btn
,
getAscii (Key.getAscii method)
handler receives one
onKillFocus
.
null
,
getCode

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash lite 2

Table of Contents