Created
August 18, 2011 13:54
-
-
Save sulram/1154112 to your computer and use it in GitHub Desktop.
AS3 image loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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