Posted By

Daxander on 08/02/10


Tagged

xml URLLoader ProgressEventPROGRESS


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

shuchii
ithnkme
tspitzr
albertomori
dubogii
elkraneo
Winkyboy


AS3: load XML


 / Published in: ActionScript 3
 

How to load XML

  1. var req:URLRequest = new URLRequest("data/data.xml");
  2. var loader:URLLoader = new URLLoader();
  3. loader.addEventListener(Event.OPEN, openHandler);
  4. loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
  5. loader.addEventListener(Event.COMPLETE, completeHandler);
  6. loader.load(req);
  7.  
  8. function openHandler(e:Event){
  9. trace("start loading");
  10. }
  11.  
  12. function progressHandler(e:ProgressEvent){
  13. trace("loaded: " + e.bytesLoaded + "total: " + e.bytesTotal);
  14. }
  15.  
  16. function completeHandler(e:Event){
  17. var loadedXML:XML=XML(e.target.data);
  18. trace("loaded: " + loadedXML.toXMLString());
  19. }

Report this snippet  

You need to login to post a comment.