Most of flex developer are getting problem with Width and Height for Dynamic Image in Flex, while uploading images, they want the Object handler( Handle border) to take the image's width and height and it should not leave whitespaces but they are unable to do this.
Here is solution for Width and hight setting of dynamic image in flex,
after loading an image you can get its contentWidth and contentHeight, with this you then calculate the aspect ratio and resize your container accordingly so that there is no white space.
i.e
MyImg.addEventListener(Event.COMPLETE,UpdateContainer)
private function UpdateContainer(e:Event):void
{
var AspectRatio : Number = MyImg.contentWidth/MyImage.contentHeight;
MyContainer.width = MyContainer.height*AspectRatio;
MyImg.width = MyContainer.width;
MyImg.height=MyContainer.height;
MyContainer.addChild(MyImg);
}
the assumption here is you are basing the container height as the fixed constant obviously you can set width as the fixed constant and adjust height by aspect ratio
Here is solution for Width and hight setting of dynamic image in flex,
after loading an image you can get its contentWidth and contentHeight, with this you then calculate the aspect ratio and resize your container accordingly so that there is no white space.
i.e
MyImg.addEventListener(Event.COMPLETE,UpdateContainer)
private function UpdateContainer(e:Event):void
{
var AspectRatio : Number = MyImg.contentWidth/MyImage.contentHeight;
MyContainer.width = MyContainer.height*AspectRatio;
MyImg.width = MyContainer.width;
MyImg.height=MyContainer.height;
MyContainer.addChild(MyImg);
}
the assumption here is you are basing the container height as the fixed constant obviously you can set width as the fixed constant and adjust height by aspect ratio
Read more...

