how can I know if an image needs to be scaled down or not?
I'm trying to create in Flex a Tile view that shows some images that a user has. The images don't have the same size, some are small and some are big.
What I'm trying to do is to use a List and create an ItemRenderer th开发者_JAVA技巧at has an Image property which displays the user images (the images are passed to the source property of the Image Object), I want the big images to scale down to the size of the tile so I set the 'scaleContnet' property of the Image Object to true, but this causes the small images to scale up to the size of the tile, this is not the behavior I want.
all the images are Embeded into Class objects and are passed as arguments to the ItemRenderer, how can I know in the ItemRenderer if I need to set the 'scaleContnet' property of the Image Object to true (for big images) or false (for small images)?
Untested, but give this a go:
<mx:Image id="img" scaleContent="{img.contentWidth > img.width || img.height > img.height}"/>
I say specify width and height inside your tag. like <mx:Image width="100" height="200" source="XXX" />
This would restrict your image size to 100 width and 200 height.
精彩评论