
Stage.removeListener() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
798
|
ActionScript Language Reference
Stage.removeListener() Method
cancels event notices for the specified listener
Flash 6
Stage.removeListener(listener)
Arguments
listener An object that was previously registered as a listener for Stage.
Returns
A Boolean: true if listener was found and removed, false if listener was not registered as
an event listener for
Stage. The return value is useful for debugging code that removes
listeners.
Description
The removeListener() method stops listener from receiving Stage event notifications. 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. To delete a
listener, first remove it with removeListener() and then delete it with the delete operator.
Example
You should remove event listeners when the task they perform is no longer required. For
example, a text field might have two display settings in an application, “percentage width”
(stretch the field to match the movie width) and “fixed width” (stay the same width). A
listener could be added to, or removed from, the field, depending on the current mode, as
follows:
// Set scaleMode to allow onResize() to operate.
Stage.align = "LT";
Stage.scaleMode = "noScale"; ...