View Full Version : understand dimension of loaded image
andrea2k
02-11-2009, 05:02 PM
I'm looking to find a way to understand the dimensions of an image that the user can load at runtime in my flex application.
Do you have any suggestion for this ?
At the moment I'm using flash player 10 and inside flex I'm loading the image from its file using mx.controls.Image.
Thankyou,
Andrea
drkstr
02-11-2009, 06:08 PM
I believe it's image.contentWidth and image.contentHeight. If not, try image.measuredWidth and image.measuredHeight.
Best Regards,
~Aaron
andrea2k
02-12-2009, 09:22 AM
I have already tried.
Looking to the debugger, I find both these properties set to 0.
I load the image from a file.
Andrea
andrea2k
02-12-2009, 11:06 AM
Ok, I found the solution by myself:
I was forgetting that the load method of mx.controls.Image is asynchronous, and hence I forgot to check the event.
I post the solution:
var img:Image = new Image();
img.addEventListener(Event.COMPLETE, imageLoaded);
img.load(byteArray);
private function imageLoaded(e:Event){
var img:Image = e.target as Image;
trace(img.contentHeight);
trace(img.measuredHeight);
}
Thx,
Andrea
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.