16.4 Beyond Observer

 <  Day Day Up  >  

In the real world, many classes broadcast events. For example, many of Flash's built-in classes ( Mouse , Selection , XML , Stage , TextField , and so on) broadcast events. The Observer pattern provides one generic blueprint for event broadcasting, but in practice most classes that broadcast events use a more complex event architecture structure. You can use Observer to good effect in simple, self-contained cases such as our application log or, say, to update objects when a stock ticker changes. You might also use Observer when implementing internal state management for a user interface component such as a slider bar or, as we'll see in Chapter 18, a clock. But for more complex event handling, you'll very likely want a more flexible, feature-rich event architecture such as the delegation event model discussed in Chapter 19. See that chapter for a detailed comparison between the Observer pattern and the delegation event model.

That completes our study of the Observer pattern. In the next chapter, we'll return to our Logger class to study its instance-creation process.

 <  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