You want to perform an action in response to an event, such as when the Stage is resized, a text field’s contents are scrolled, the mouse button is clicked, or a key is pressed.
Create a listener object that defines
an appropriate listener event handler and
add it as a listener using
allow one or more objects to respond to events that occur for other
listener object (an
object that has been added as a
listener) is notified when one of the supported listener events
occurs. For example, the built-in
Stage objects generate one or more listener
events, as do instances of the
shown in Table 12-1.
Table 12-1. Listener events for built-in objects and instances
Built-in listener events
A listener object can be any kind of object, such as a text field,
movie clip, or custom object. The listener object must define a
listener event handler to respond to the event of interest, and it
must be added as a listener using
). For example, to respond to text-scrolling events, you
can create an object that defines an
) method and then register the object to the text field of
interest using the
addListener( ) method. ...