External File Load Methods


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. private function loadContent(path:String, x:Number = 0, y:Number = 0):void
  2. {
  3. var ldr:Loader = new Loader();
  4. var url:String = path;
  5. var urlReq:URLRequest = new URLRequest(url);
  6. ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
  7. ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
  8. ldr.load(urlReq);
  9. ldr.x = x;
  10. ldr.y = y;
  11. addChild(ldr);
  12. }
  13.  
  14. // callbacks
  15.  
  16. private function onLoadComplete(e:Event):void
  17. {
  18.  
  19.  
  20. }
  21.  
  22. private function onLoadProgress(e:ProgressEvent):void
  23. {
  24. var kbl:Number = e.bytesLoaded;
  25. var tkb:Number = e.bytesTotal;
  26.  
  27. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.