03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

onKeyUp (Button.onKeyUp h<strong>and</strong>ler)<br />

onKeyUp = function() {}<br />

Invoked when a button has input focus <strong>and</strong> a key is released. The onKeyUp event h<strong>and</strong>ler is<br />

invoked with no parameters. You can use the Key.getAscii() <strong>and</strong> Key.getCode() methods<br />

to determine which key was pressed.<br />

Example<br />

In the following example, a function that sends text to the Output panel is defined for the<br />

onKeyDown h<strong>and</strong>ler. Create a button called my_btn on the Stage, <strong>and</strong> enter the following<br />

ActionScript in a frame on the Timeline:<br />

my_btn.onKeyDown = function() {<br />

trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")");<br />

};<br />

my_btn.onKeyUp = function() {<br />

trace("onKeyUp: "+this._name+" (Key: "+getKeyPressed()+")");<br />

};<br />

function getKeyPressed():String {<br />

var theKey:String;<br />

switch (Key.getAscii()) {<br />

case Key.BACKSPACE :<br />

theKey = "BACKSPACE";<br />

break;<br />

case Key.SPACE :<br />

theKey = "SPACE";<br />

break;<br />

default :<br />

theKey = chr(Key.getAscii());<br />

}<br />

return theKey;<br />

}<br />

Press Control+Enter to test the SWF file. Make sure you select Control > Disable Keyboard<br />

Shortcuts in the test environment. Then press the Tab key until the button has focus (a yellow<br />

rectangle appears around the my_btn instance) <strong>and</strong> start pressing keys on your keyboard.<br />

When you press keys, they are displayed in the Output panel.<br />

See also<br />

onKeyDown (Button.onKeyDown h<strong>and</strong>ler), getAscii (Key.getAscii method), getCode<br />

(Key.getCode method)<br />

onKillFocus (Button.onKillFocus h<strong>and</strong>ler)<br />

onKillFocus = function(newFocus:Object) {}<br />

Button 263

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!