19.2 The Flow of Logic

 <  Day Day Up  >  

Figure 19-1 shows the structure and logic flow of the delegation event model in diagrammatic form. The steps shown in the figure are as follows :

  1. An instance of the event source ( EventSourceClass ) is created.

    1. The event source creates and stores an instance of EventListenerList .

    2. An instance of the event listener ( EventListenerClass ) is created and registers to receive events from the event source.

    3. The event listener is stored by the event source's EventListenerList .

    4. An event occurs and is broadcast by the event source as follows:

    5. The event source creates an event object ( EventObject ) instance describing the event.

    6. The event source invokes the appropriate method ( onEventName( ) ) on all registered event listeners, passing along the event object that describes the event.

  2. Each event listener processes the event in its own way, using the event object to determine how to respond to the event.

In Figure 19-1, italic type indicates the part of a name that is customized per implementation. The names used reflect the formal convention for the delegation event model. The parameter, l , passed to addEventTypeListener( ) and removeEventTypeListener( ) in Figure 19-1 is the listener to be added or removed.

Figure 19-1. Logic flow in the delegation event model
figs/as2e_1901.gif

Later, in Figure 19-2, we'll compare the abstract roles shown in Figure 19-1 with real examples.

 <  Day Day Up  >  


Essential ActionScript 2.0
Essential ActionScript 2.0
ISBN: 0596006527
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Colin Moock

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net