03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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 />

Invoked when a button loses keyboard focus. The onKillFocus h<strong>and</strong>ler receives one<br />

parameter, newFocus, which is an object representing the new object receiving the focus. If no<br />

object receives the focus, newFocus contains the value null.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<br />

Parameters<br />

newFocus:Object - The object that is receiving the focus.<br />

Example<br />

The following example demonstrates how statements can be executed when a button loses<br />

focus. Create a button instance on the Stage called my_btn <strong>and</strong> add the following<br />

<strong>ActionScript</strong> to Frame 1 of the Timeline:<br />

this.createTextField("output_txt", this.getNextHighestDepth(), 0, 0, 300,<br />

200);<br />

Button 371

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

Saved successfully!

Ooh no, something went wrong!