Skip to content

Instantly share code, notes, and snippets.

@kara-ryli
Created June 8, 2012 19:16
Show Gist options
  • Save kara-ryli/2897659 to your computer and use it in GitHub Desktop.
Save kara-ryli/2897659 to your computer and use it in GitHub Desktop.
Getting the height and width of a loaded image in ActionScript
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function (event:Event):void {
// although these two values are the same, accessing the later doesn't
// work unless your image is on the same server as the HTML page, or
// you tell the loader to check a policy file first.
trace("loader width: " + loader.width); // Works
trace("bitmap width: " + loader.content.width); // Exception
});
loader.load(new URLRequest("http://www.example.com/image.png"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment