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

Example: Weather Maps

The National Oceanic and Atmospheric Administration (NOAA), a division of the U.S. Department of Commerce, runs a Geostationary Satellite Server on the Web (http://www.goes.noaa.gov). The site publishes satellite images of the United States, including Puerto Rico, Alaska, and Hawaii. We will use these images (they're in the public domain and free to use) to develop a simple weather map application leveraging the MVC pattern. For this example we will use the built-in user interface components provided in Flash CS3 to develop view elements.

For the first iteration of our application shown in Figure 12-3, we'll allow the user to choose the map region (East Coast, West Coast, Puerto Rico, Alaska, and Hawaii) using a combo box (a drop-down list that displays the currently chosen item). The application will then load the latest visible satellite image of the corresponding region.

Weather map example application showing a visible map of the East Coast

Figure 12-3. Weather map example application showing a visible map of the East Coast

This example illustrates the use of built-in components in Flash CS3 to implement the user interface elements in each view. It also shows the usefulness of nested views for screen layout and automatic view updates. Let's create the model element of our example application.

The Model

The model element of the MVC pattern contains the application data and state including the logic to manage data and state. The application ...

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