Maintaining BackgroundImage Aspect Ratio

Maintaining BackgroundImage Aspect Ratio

Post by jaldag » Fri, 30 May 2008 11:39:18


Just started today with Flex3. I'm having trouble maintaining the aspect ratio
of my background image. With the browser maximized the picture is stretched.
When the browser is made smaller the aspect ratio is correct. I'm hoping to
have the correct aspect ratio throughout even if that means the photo will be
cropped a bit. Anyone wanna tackle this?
Thanks.
Jason

PS Tried width and height at 100%, auto as well....
 
 
 

Maintaining BackgroundImage Aspect Ratio

Post by Greg Lafra » Fri, 30 May 2008 14:02:02

You can achieve this by setting backgroundSize to anything other than a
percentage. In the following code, the image I used was 600 width, 398 height.
I can set backgroundSize to 600, 2000, 1, and the image always displays at its
actual size. Set it to 100%, 50%, etc. and you lose the aspect ratio when
sizing browser.

<?xml version="1.0"?>
<mx:Application xmlns:mx=" http://www.yqcomputer.com/ "
backgroundImage="images\france_agriculture.jpg" backgroundSize="600">
</mx:Application>