mx:Image is the component that loads the image as a child and not the
image itself.

 

"complete" is fired when all the bytes of the image are downloaded.

 

You see complete, then the Image wrapper does and adjusts its size.  An
updateComplete will be dispatched when it is sized.  Different layout
issues could cause some shifting over subsequent frames.

 

The actual size of the image is in content.loaderInfo.width/height and
shoule be available on complete.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Grigg
Sent: Wednesday, March 21, 2007 1:43 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Complete event from mx:Image

 

Does anyone know why the mx:Image fires the complete event before the
image has been completely loaded?

I have the following code

private function photoComplete(event:Event):void
{
trace (photo_img.width + ' ' + photo_img.height);
}

<mx:Image id="photo_img" complete="photoComplete(event)"/>

When the photoComplete gets called the width and height are traced out
as '0'. What I had to do was add a little logic snippet to say if the
width and height are '0' do a callLater, and call back to the
photoComplete again, sometimes it takes 2 or 3 callbacks for the size
to register.

Any idea why? I would think that when the 'complete' gets fired the
mx:Image should know the size of the picture it has loaded.

Derrick

 

Reply via email to