Posted By

mrbassman12 on 03/26/09


Tagged

external loader as3


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

damarev
mrbassman12


Load external swf with loader class


 / Published in: ActionScript 3
 

  1. import flash.net.URLRequest;
  2. import flash.display.Loader;
  3. import flash.events.Event;
  4. import flash.events.ProgressEvent;
  5.  
  6. function startLoad()
  7. {
  8. var mLoader:Loader = new Loader();
  9. var mRequest:URLRequest = new URLRequest("MouseActions.swf");
  10. mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
  11. mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
  12. mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
  13. mLoader.load(mRequest);
  14. }
  15.  
  16. function onCompleteHandler(loadEvent:Event)
  17. {
  18. addChild(loadEvent.currentTarget.content);
  19. }
  20. private function errorHandler(errorEvent:Event):void {
  21. trace("file not found")
  22. }
  23. function onProgressHandler(mProgress:ProgressEvent)
  24. {
  25. var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
  26. trace(percent);
  27. }
  28. startLoad();

Report this snippet  

You need to login to post a comment.