O'Reilly logo

ActionScript 3.0 Design Patterns by Chandima Cumaranatunge, William Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extended Example: Infrared Weather Maps

To illustrate how the MVC pattern allows for flexible expansion and reuse of its model, view, and controller elements, we will extend our weather maps example. You may have noticed that there are three types of satellite image maps on the Geostationary Satellite Server web site (http://www.goes.noaa.gov). What if we want to give the user the option of choosing whether to view a visible or infrared image? What changes would be required to extend our weather maps application to view infrared satellite images?

To begin with, we'll need to add another view such as a radio button group to choose the type of satellite image (visible or infrared as shown in Figure 12-5).

Extended example showing an infrared map of the West Coast

Figure 12-5. Extended example showing an infrared map of the West Coast

We will need to create a new controller to handle the user input to the new view element. Our model will also need to hold more data, as we need to integrate five additional image URLs, one for each region as an infrared image. The application logic in the model will also need to be updated to handle the new data. Can we add all these new features without changing existing code? Can we leverage the flexibility and reuse of the MVC pattern without breaking anything?

Let's look at the changes needed to update the model.

Adding a New Model

Instead of modifying the current weather maps model (Example 12-13), we will extend ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required