Nov

2

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

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. » Flash ActionScript Detect Get Image Width Height | Highub - Web … on November 2, 2008 12:21 am

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

Sponsors




Links