/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.events.*; import flash.display.Loader; import flash.display.LoaderInfo; import flash.net.URLLoader; import flash.net.URLRequest; var url:String = "http://domain.com/image.png"; var myLoader:Loader; myLoader= new Loader(); myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress); myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); myLoader.load(new URLRequest(url)); function onProgress(e:ProgressEvent):void { var p:Number = (e.bytesLoaded / e.bytesTotal); } function onComplete(e:Event):void { myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress); //e.target.content.bitmapData stage.addChild(myLoader); }