Try using the 'complete' event.

 

- Gordon

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Russell Sprague
Sent: Thursday, January 18, 2007 4:41 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Image source doesn't affect Image size?

 

It seems that if an image is loaded into an Image tag at runtime, the 
size is w=0 h=0, ex.

private var imgsrc:String;
public function loadImage(val:String):void{
imgsrc = "assets/images/"+val;
}
private function imgLoaded(e:Event):void{
trace("tw "+this.width);
trace("iw "+bImage.width);
trace(e.target.width);
}
...
<mx:Image id="bImage" source="{imgsrc}" complete="imgLoaded(event)" 
horizontalCenter="0" verticalCenter="0"/>

if I call the loadImage function with a image url string,
even after the image loads into the Image tag, it returns 0 for the 
width and height of the Image tag.

I tried using a callLater function in the loadImage function, but it 
gave the same results.

Is there a way to get the width and height of an Image tag if it loads 
in an image at runtime?

Thanks
Russ

 

Reply via email to