Created
June 8, 2012 19:16
-
-
Save kara-ryli/2897659 to your computer and use it in GitHub Desktop.
Getting the height and width of a loaded image in ActionScript
This file contains hidden or 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 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