
Key.addListener() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
558
|
ActionScript Language Reference
Usage
The onKeyDown( ) and onKeyUp( ) listener events were added to the Key object in Flash 6.
They are preferred over MovieClip.onKeyDown( ) and MovieClip.onKeyUp( ) and the Flash
5–style onClipEvent(keyDown) and onClipEvent(keyUp) handlers in most cases.
However, the following caveats apply:
• In Flash 6, the updateAfterEvent( ) function, which refreshes the screen between
frames, can be used only with MovieClip mouse and key events and setInterval( ).
Hence, to create instant-refresh keyboard applications, use onClipEvent(keyDown) and
onClipEvent(keyUp), which are directly analogous to Key.onKeyDown( ) and Key.
onKeyUp( ).
• To capture keystrokes while a specific movie clip has input focus only, use the
MovieClip.onKeyDown( ) and MovieClip.onKeyUp( ) handlers. See those entries for
details.
See Also
MovieClip.onKeyDown( ), MovieClip.onKeyUp( ); Chapter 10, Appendix B
Key.addListener() Method
registers an object to receive onKeyDown() and onKeyUp() events
Flash 6
Key.addListener(listener)
Arguments
listener An object with a defined onKeyDown( ) and/or onKeyUp( ) method.
Description
The addListener( ) method adds listener to the list of objects notified when Key’s
onKeyDown( ) and onKeyUp( ) events occur. The
listener is an object