|
Essential ActionScript 2.0 Authors: Moock C. Published year: 2004 Pages: 138-139/177 |
| < Day Day Up > |
18.4 Further ExplorationBecause our clock is an MVC application, it is incredibly flexible. New interfaces, input responses, and functionality can easily be added to the clock. If you're keen to experiment with MVC in ActionScript, try the following exercises:
If you'd like to continue reading about the MVC design pattern, see the following online articles:
In the next (and final) chapter, we'll continue our coverage of interclass update mechanisms by studying the delegation event model. |
| < Day Day Up > |
| < Day Day Up > |
Chapter 19. The Delegation Event Model
In Chapter 16, we used the Observer pattern to structure a group of objects so that when one changes state, the others are automatically notified. As we learned in Chapter 16, the Observer pattern is intentionally generic, emphasizing loose coupling between the object that changes (the subject ) and the objects being notified of the change (the observers ). In this chapter, we'll apply the concepts of the Observer pattern to a more specific situation: implementing events for a class. Our event implementation will follow Java's delegation event model , a general design for event broadcasting. The delegation event model framework we'll develop in this chapter can be used to implement event broadcasting for any class. For example, a Chat class might use it to implement onChatMessage( ) or onUserNameChanged( ) events. An interactive WorldMap class might likewise implement onCountryClick( ) , onCountryRollover( ), and onCountryRollout( ) events. Or a ChessGame class might implement onCheckMate( ) , onPieceTaken( ) , and onMove( ) events. In each case, the delegation event model provides a basic structure for the event source ( Chat , WorldMap , and ChessGame ) and the event listeners (objects that register to receive events from an event source). As usual, the code discussed in this chapter is available at http:// moock .org/eas2/examples. |
| < Day Day Up > |
|
Essential ActionScript 2.0 Authors: Moock C. Published year: 2004 Pages: 138-139/177 |