Model class

package flashscriptMVC
{
	import flashscriptMVC.IModel;
	import flash.events.*;
	import flash.display.DisplayObject;
	import flash.net.URLLoader;
	import biz.flashscript.utils.LoadData;
	import flash.net.URLRequest;
	
	public class Model extends EventDispatcher implements IModel
	{
		protected var xmlData:XML;
		private var _alertText:String;
		private var _alertYesno:Boolean;
		private var _alertTarget:Object;
		public static const ALERT_WINDOW:String = "alertWindow";
		public static const VIEW_WINDOW:String = "viewWindow";
		public static const SERVER_ERROR:String = "serverError";
		public static const SERVER_RESPONSE:String = "serverResponse";
		public function Model (myXML:String):void
		{
/*
* The Model class is designed in that way that it can be used 
* for other forms as well or for applications, which send data
* to the server and get a response from the server. It is completely
* separated from the viewers.
*
* A major task of the Model class is to load an XML file with
* data for the Login and Alert viewers. Those are Labels, URLs
* and messages. We could also add parameters for the movie here.
*/
			var urlLoader:URLLoader = new URLLoader  ;
			var urlRequest:URLRequest = new URLRequest(myXML);
			urlLoader.load (urlRequest);
			urlLoader.addEventListener (Event.COMPLETE,onComplete);
		}
		public function onComplete (evt:Event):void
		{
			try
			{
				var xml:XML = new XML(evt.currentTarget.data);
				setXML (xml);
			}
			catch (evt:TypeError)
			{
				trace ("Could not parse text into XML");
				trace (evt.message);
			}
		}
/*
* The Model class has a number of getter - setter functions. One of
* the functions is to set focus on an object.
*/
		public function focusObject (target:Object):void
		{
			target.setFocus ();
		}
/*
* Functions to make the XML available for the viewers.
*/
		public function setXML (_xml:XML):void
		{
			xmlData = _xml;
			update ("viewWindow");
		}
		public function getXMLData ():XML
		{
			return xmlData;
		}
/*
* Functions to set an Alert. The following functions set the
* Alert parameters and are Getters for the viewers to get the
* parameters.
*/
		public function alert ():void
		{
			update ("alertWindow");
		}
/*
* Getters and Setters for the Alert variables.
*/
		public function set alertText (a:String):void
		{
			_alertText = a;
		}
		public function get alertText ():String
		{
			return _alertText;
		}
		//
		public function set alertYesno (a:Boolean):void
		{
			_alertYesno = a;
		}
		public function get alertYesno ():Boolean
		{
			return _alertYesno;
		}
		//
		public function set alertTarget (t:Object):void
		{
			_alertTarget = t;
		}
		public function get alertTarget ():Object
		{
			return _alertTarget;
		}
/*
* Response back to the viewer when the handling was ok or gave an error.
*/
		public function okayHandler ():void
		{
			update ("serverResponse");
		}
		public function errorHandler ():void
		{
			update ("serverError");
		}
/*
* This function always updates the viewers. It can handle several
* different event handlers.
*/
		protected function update (evtType:String):void
		{
			dispatchEvent (new Event(evtType));
		}
	}
}