TextField.removeListener( ) Method

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

cancels event notices for the specified listener
theField.removeListener(listener)

Arguments

listener

An object that was previously registered as a listener for theField.

Returns

A Boolean: true if listener was found and removed, false if listener was not registered as an event listener for theField. The return value is useful for debugging code that removes listeners.

Description

The removeListener( ) method stops listener from receiving notification of onScroller( ) and onChanged( ) events occurring on theField. It should be used only after listener has been registered as an event listener via addListener( ). The listener object is not deleted, but it can be removed and added repeatedly. Event listeners normally are removed when the task they perform is no longer required. For example, a listener that controls a scrollbar could be removed when an application enters a disabled state due to, say, the launching of a modal dialog box.

Example

// Make a text field that accepts user input. this.createTextField("theField_txt", 1, 0, 0, 200, 20); theField_txt.border = true; theField_txt.type = "input"; // Create a listener. txtListener = new Object(); // Add the onScroller function to the listener. txtListener.onScroller = function (tfObject) {   trace(tfObject + " scroll property changed."); } // This adds the listener to theField_txt. theField_txt.addListener(txtListener); // This removes the listener from theField_txt. theField_txt.removeListener(txtListener); // This also removes the listener from theField_txt, but it // displays an error message if the listener is not found. if (!theField_txt.removeListener(txtListener)) {   trace("ERROR. No such listener on theField_txt."); }

See Also

TextField.addListener( ), TextField.onChanged( ), TextField.onScroller( ); 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