Key.addListener( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Key.addListener( ) Method Flash 6

registers an object to receive onKeyDown( ) and onKeyUp( ) events
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 of any class that defines methods by the name onKeyDown and/or onKeyUp; these need not be built-in methods of the object but can instead be custom-defined. The methods are invoked when the corresponding event occurs for Key. To stop a listener object from receiving events, use Key.removeListener( ).

Multiple objects can respond independently to each Key event. When multiple listeners are registered to Key, their methods are invoked in the order the listeners were added.

For general information on how listeners and callback functions work, see Chapter 10. For sample Key listener code, see Key.getAscii( ) and Key.onKeyDown( ).

See Also

Key.getAscii( ), Key.onKeyDown( ), Key.onKeyUp( ), Key.removeListener( ); Chapter 10



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net