You can get the width and height of the image using the ImageLoader object public functions getWidth
and getHeight
but you need to know when the load is complete, so you could dispatch a event from ImageLoader completeHandler, like:
// declare public static constant
public static const COMPLETE : String = "complete";
// inside complete handler
dispatchEvent(new Event(ImageLoader.COMPLETE));
done with this you can now listen to this event from your Main class like this:
myImg2 = new ImageLoader( img2 );
myImg2.addEventListener(ImageLoader.COMPLETE, onImageLoadComplete);
// inside onImageLoadComplete handler you can read the width and height:
private function loadComplete(evt : Event) : void
{
trace (ImageLoader(evt.currentTarget).getWidth());
trace (ImageLoader(evt.currentTarget).getHeight());
}
dome
2010-02-24 09:05:18