/******************************************
 * @author Maria A. Zamora
 * @company Digitec Interactive Inc.
 * @version 0.1
 * @date 12/14/2010
 * 
 * xml file loader that dispatch an event when xml is loaded
 * CS5 version of com.digitec.cee.XMLLoader
 *  
*******************************************/ 
package com.digitec.cee
{
	import flash.events.EventDispatcher;
	import flash.net.URLLoader;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	public class XMLLoader extends EventDispatcher
	{
		private var urlLoader:URLLoader;
		private var urlRequest:URLRequest;
		private var xmlpath2:String;
		public var _xml:XML;
		private var counter:int=0;
		private var xmlRequestArr:Array
		
		public function XMLLoader():void
		{
			this.xmlRequestArr=new Array()
		}
		
		public function loadXML(filepath:String, xmlRef:String):void
		{
			this.xmlpath2=filepath;
			this.xmlRequestArr.push(xmlRef)
			this.urlLoader = new URLLoader();
			this.urlRequest=new URLRequest(this.xmlpath2);
			this.urlLoader.addEventListener(Event.COMPLETE, completeHandler);
			this.urlLoader.load(this.urlRequest);
		}
		
		private function completeHandler(evt:Event)
		{
			this._xml=new XML(evt.target.data);
			this.dispatchEvent(new CustomEvent(CustomEvent.XMLLoaded,this.xmlRequestArr[this.counter],this._xml));
			this.counter++
		}
		
		//private function xmlLoadError(e:Event):void {}			
		
	} //class
} //package

