AS3: Using URLLoader for Text and XML


/ Published in: ActionScript 3
Save to your folder(s)

URLLoader is not the same as Loader. It is meant to load text, html, sound, xml, and swf content. If you want to load an image, use Loader().


Copy this code and paste it in your HTML
  1. var assetLoader:URLLoader = new URLLoader();
  2. assetLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
  3. assetLoader.addEventListener(Event.COMPLETE, completeHandler);
  4.  
  5. function progressHandler(e:Event):void
  6. {
  7. trace(e.currentTarget.bytesLoaded + " / " + e.currentTarget.bytesTotal);
  8. }
  9. function completeHandler(e:Event):void
  10. {
  11. trace("completeHandler:" + e.currentTarget + " :: " + e.currentTarget.dataFormat + " :: " + e.currentTarget.data);
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.