Posted By

marzsman on 04/04/11


Tagged

xml URLLoader


Versions (?)

Load XML file


 / Published in: ActionScript 3
 

Load an XML and pars it

  1. private function loadXML(url:String):void
  2. {
  3. loader = new URLLoader();
  4. loader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
  5. loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
  6. loader.load(new URLRequest(url));
  7. }
  8.  
  9. private function onComplete(event:Event):void
  10. {
  11. try
  12. {
  13. _xmlData = new XML(event.target.data);
  14. loader.removeEventListener(Event.COMPLETE, onComplete);
  15. loader.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
  16. }
  17.  
  18. catch (err:Error)
  19. {
  20. trace("Could not parse loaded content as XML:\n" + err.message);
  21. }
  22. }
  23.  
  24. private function onIOError(e:Event):void
  25. {
  26. trace(e);
  27. }

Report this snippet  

You need to login to post a comment.