tags:

views:

77

answers:

1

I have some code to scale an image's width according to its height after the image is being loaded. It works fine on my development PC if I point to the wrapper html using local file system path. However, after I deploy the web application to JBoss AS 5.1, it stopped working - it always sets the image width to 0, causing it to disappear. Anyone else experience similar issues?

Code for scale image side:

private function scaleImage():void {
    img.width = img.contentWidth;
}

<mx:Image id="img" updateComplete="callLater(scaleImage)" height="100%" />
A: 

I imagine it's because you're hooking the wrong event and it hasn't loaded by the time callLater is called. Are you sure that updateComplete is the right event?

complete looks like a better choice of event:

http://livedocs.adobe.com/flex/3/langref/mx/controls/SWFLoader.html#event%3Acomplete

Of course, if you've migrated your app from a Windows environment to a case sensitive environment, case-sensitivity in the path might be an issue.

spender
updateComplete is the right event, it's only at updateComplete that the image is measured and laid out. If you listen for complete, you won't get the correct content width.case in the path is not the issue either: it's all lower case.
Tong Wang