Return to Snippet

Revision: 6209
at May 7, 2008 22:30 by wintondeshong


Initial Code
/**
 * Base PureMVC Project
 */
package model
{
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    
    import org.puremvc.as3.interfaces.IProxy;
    import org.puremvc.as3.patterns.proxy.Proxy;

	import ApplicationFacade;

    public class DataProxy extends Proxy implements IProxy
    {
        public static const NAME:String = "DataProxy";

        public function DataProxy()
        {
			trace ("DataProxy instantiated");
        	/**
        	 * Here, we initialize DataProxy with a var named "data" 
        	 * of type Object(), a built-in property of the Proxy class. 
        	 * This var will be used for storing data retrieved from the xml document.
        	 */
            super( NAME, new Object() );
            
            var loader:URLLoader = new URLLoader();
            loader.addEventListener( Event.COMPLETE, onDataLoaded );
			loader.load( new URLRequest( "data.xml" ) );

        }
		
		private function onDataLoaded( evt:Event ):void
		{
			trace ("DataProxy.onDataLoaded()");
			
			var xml:XML = new XML( evt.target.data );
			xml.ignoreWhitespace = true;
			
			
			/**
			 * When DataProxy is done loading and parsing data, it 
			 * sends an INITIALIZE_SITE notification back to the framework.
			 */
			sendNotification( ApplicationFacade.INITIALIZE_SITE );
		}		
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
PureMVC XML DataProxy Class Template

Initial Tags
class, textmate, template

Initial Language
Other