I've been struggling with this problem for far to long now, and I'm guessing the solution is quite easy.
In my Flex application, I've got a component that extends UIComponent where I'm loading images at runtime and try to display them. I've tried lots of different approaches (using beginBitmapFill(), using different containers), but I can't get things to work as I want. The problem seems to be related to the width and height properties of the image, which aren't updated correctly. The idea is:
var sprite:Sprite = new Sprite();
addChild(sprite);
var im:Image = new Image();
im.addEventListener(Event.COMPLETE, function(e:Event):void {
sprite.addChild(im);
}
im.load('path/image.png');
The image's width and height doesn't seem to be correct when it's loaded. I get width==0 (and nothing is displayed), but the property $width seems to be correct. How can I assure that width and height of the loaded image is updated?