Example: Working with Different Data Displays | 317
Example: Working with Different Data Displays
The last example showed how quickly changing data could be sent to a central
object, and then sent out to subscribers. It also illustrated how subscribers could be
dynamically unsubscribed. We showed some minimal output difference in the three
combatants’ window displays, but the differences were minimal. Now, we’ll look at
some seriously different output displays and introduce an additional interface.
The Output Designer
In the original design pattern book, the GoF provided a simple diagram for illustrat-
ing one use of the Observer pattern. A single source of data was sent to different
objects that would display the data in a table, a bar chart, and a pie chart. This
seemed like a good way to demonstrate some of Flash 9’s and ActionScript 3.0’s
components and graphic capabilities using the Observer pattern. For our example,
let’s use a list bo xcomponent, and then show how to create both a bar chart and line
chart with ActionScript.
Figure 8-6. Destroyed combatant is unsubscribed