Example: Weather Maps | 445
The next step is to implement the IModel interface and develop the model
(Example 12-13).
Example 12-12. IModel.as (Model interface for the weather map example)
package
{
import flash.events.*;
public interface IModel extends IEventDispatcher
{
function getRegionList( ):Array
function getRegion( ):uint
function setRegion(index:uint):void
function getMapURL( ):String
}
}
Example 12-13. Model.as (Model for the weather map example)
package {
import flash.events.*;
public class Model extends EventDispatcher implements IModel
{
protected var aRegions:Array;
protected var chosenRegion:uint;
protected var aImageURLs:Array;
public function Model( )
{
this.aRegions = new Array(
"East Coast",
"West Coast",
"Puerto Rico",
"Alaska",
"Hawaii");
this.aImageURLs = new Array(
"http://www.goes.noaa.gov/GIFS/ECVS.JPG",
"http://www.goes.noaa.gov/GIFS/WCVS.JPG",
"http://www.goes.noaa.gov/GIFS/PRVS.JPG",
"http://www.goes.noaa.gov/GIFS/ALVS.JPG",
"http://www.goes.noaa.gov/GIFS/HAVS.JPG");
this.chosenRegion = 0;
}
public function getRegionList( ):Array
{
return aRegions;
}