Nov
2
Flash ActionScript Detect Get Image Width Height
November 2, 2008 |
If you dynamically load an image using loadclip and try to get the image dimension - width and height, here is the how to.
Imagine you want to load http://www.w3.org/Icons/w3c_main.png into your Flash movie, and get the image w3c_main.png width and height, copy and paste the following script into the first frame of your Flash movie, you will see the traced result from Output:
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadInit = function(target:MovieClip):Void {
trace(target + ".onLoadInit");
trace("Width: " + target._width);
trace("Height: " + target._height);
}
mcLoader.addListener(listener);
mcLoader.loadClip("http://www.w3.org/Icons/w3c_main.png", container);
Similar Posts
- Flash ActionScript Detect Mouse Press and Hold
- Flash Ball Collision Prevent Stick and Rotate
- ComboBox Dropdown Popup List Appears Behind
Comments
1 Comment so far



































[...] Highub - Web Development Blog · Home · About · Bookmarks · Music · Portfolio. Categories. Flash ActionScript Detect Get Image Width Height | Highub - Web … [...]