Flash Lite 2.x and 3.0 ActionScript Language Reference

removeListener (TextField.removeListener method)

public removeListener(listener:Object) : Boolean

Removes a listener object previously registered to a text field instance with TextField.addListener().

Parameters

listener:Object - The object that will no longer receive notifications from TextField.onChanged or TextField.onScroller.

Returns

Boolean - If listener was successfully removed, the method returns a true value. If listener was not successfully removed (for example, if listener was not on the TextField object's listener list), the method returns a value of false.

Example

The following example creates an input text field called my_txt. When the user types into the field, information about the number of characters in the text field is displayed in the Output panel. When the user types into the field, information about the number of characters in the text field writes to the log file. If the user clicks the removeListener_btn instance, then the listener is removed and information is no longer displayed. If the user clicks the removeListener_btn instance, then the listener is removed and information no longer writes to the log file.

this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 160, 20);
my_txt.border = true;
my_txt.type = "input";

var txtListener:Object = new Object();
txtListener.onChanged = function(textfield_txt:TextField) {
    trace(textfield_txt+" changed. Current length is: "+textfield_txt.length);
};
my_txt.addListener(txtListener);

removeListener_btn.onRelease = function() {
    trace("Removing listener...");
    if (!my_txt.removeListener(txtListener)) {
    trace("Error! Unable to remove listener");
    }
};

(