10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example 12-12. IModel.as (Model interface for the weather map example)<br />

package<br />

{<br />

import flash.events.*;<br />

}<br />

public interface IModel extends IEventDispatcher<br />

{<br />

function getRegionList( ):Array<br />

function getRegion( ):uint<br />

function setRegion(index:uint):void<br />

function getMapURL( ):String<br />

}<br />

The next step is to implement the IModel interface and develop the model<br />

(Example 12-13).<br />

Example 12-13. Model.as (Model for the weather map example)<br />

package {<br />

import flash.events.*;<br />

public class Model extends EventDispatcher implements IModel<br />

{<br />

protected var aRegions:Array;<br />

protected var chosenRegion:uint;<br />

protected var aImageURLs:Array;<br />

public function Model( )<br />

{<br />

this.aRegions = new Array(<br />

"East Coast",<br />

"West Coast",<br />

"Puerto Rico",<br />

"Alaska",<br />

"Hawaii");<br />

this.aImageURLs = new Array(<br />

"http://www.goes.noaa.gov/GIFS/ECVS.JPG",<br />

"http://www.goes.noaa.gov/GIFS/WCVS.JPG",<br />

"http://www.goes.noaa.gov/GIFS/PRVS.JPG",<br />

"http://www.goes.noaa.gov/GIFS/ALVS.JPG",<br />

"http://www.goes.noaa.gov/GIFS/HAVS.JPG");<br />

this.chosenRegion = 0;<br />

}<br />

public function getRegionList( ):Array<br />

{<br />

return aRegions;<br />

}<br />

Example: Weather Maps | 445

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!