Skip to content

Instantly share code, notes, and snippets.

@sulram
Created August 18, 2011 13:54
Show Gist options
  • Save sulram/1154112 to your computer and use it in GitHub Desktop.
Save sulram/1154112 to your computer and use it in GitHub Desktop.
AS3 image loader
var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);
var fileRequest:URLRequest = new URLRequest("myImage.jpg");
myLoader.load(fileRequest);
public function onProgressStatus(e:ProgressEvent) {
// this is where progress will be monitored
trace(e.bytesLoaded, e.bytesTotal);
}
public function onLoaderReady(e:Event) {
// the image is now loaded, so let's add it to the display tree!
addChild(myLoader);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment