We Recommend

HTML Dog: The Best-Practice Guide to XHTML and CSS HTML Dog: The Best-Practice Guide to XHTML and CSS
For readers who want to design Web pages that load quickly, are easy to update, accessible to all, work on all browsers and can be quickly adapted to different media, this comprehensive guide represents the best way to go about it.


Posted By

wintondeshong on 05/07/08


Tagged

class textmate template actionscript3 PureMVC proxy


Versions (?)


PureMVC XML DataProxy Class Template


Published in: Other 


  1. /**
  2. * Base PureMVC Project
  3. */
  4. package model
  5. {
  6. import flash.events.Event;
  7. import flash.net.URLLoader;
  8. import flash.net.URLRequest;
  9.  
  10. import org.puremvc.as3.interfaces.IProxy;
  11. import org.puremvc.as3.patterns.proxy.Proxy;
  12.  
  13. import ApplicationFacade;
  14.  
  15. public class DataProxy extends Proxy implements IProxy
  16. {
  17. public static const NAME:String = "DataProxy";
  18.  
  19. public function DataProxy()
  20. {
  21. trace ("DataProxy instantiated");
  22. /**
  23. * Here, we initialize DataProxy with a var named "data"
  24. * of type Object(), a built-in property of the Proxy class.
  25. * This var will be used for storing data retrieved from the xml document.
  26. */
  27. super( NAME, new Object() );
  28.  
  29. var loader:URLLoader = new URLLoader();
  30. loader.addEventListener( Event.COMPLETE, onDataLoaded );
  31. loader.load( new URLRequest( "data.xml" ) );
  32.  
  33. }
  34.  
  35. private function onDataLoaded( evt:Event ):void
  36. {
  37. trace ("DataProxy.onDataLoaded()");
  38.  
  39. var xml:XML = new XML( evt.target.data );
  40. xml.ignoreWhitespace = true;
  41.  
  42.  
  43. /**
  44. * When DataProxy is done loading and parsing data, it
  45. * sends an INITIALIZE_SITE notification back to the framework.
  46. */
  47. sendNotification( ApplicationFacade.INITIALIZE_SITE );
  48. }
  49. }
  50. }

Report this snippet 

You need to login to post a comment.