removeListener (Key.removeListener method)

public static removeListener(listener:Object) : Boolean

Removes an object previously registered with Key.addListener().

Availability: ActionScript 1.0; Flash Player 6

Parameters

listener:Object - An object.

Returns

Boolean - If the listener was successfully removed, the method returns true. If the listener was not successfully removed (for example, because the listener was not on the Key object's listener list), the method returns false.

Example

The following example moves a movie clip called car_mc using the Left and Right arrow keys. The listener is removed when you press Escape, and car_mc no longer moves.

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    switch (Key.getCode()) {
    case Key.LEFT :
    car_mc._x -= 10;
    break;
    case Key.RIGHT :
    car_mc._x += 10;
    break;
    case Key.ESCAPE :
    Key.removeListener(keyListener);
    }
};
Key.addListener(keyListener);

Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001771.html