Thanks for the tips, yes you understood correctly. With the Canvas clipping and the image pinned to the center and the following calculations/algorithm on image load and resize it is working like a charm.
var containerWidth:int = mainContent.width; var containerHeight:int = mainContent.height; var imageWidth:int = bgImage.contentWidth; var imageHeight:int = bgImage.contentHeight; var containerRatio:Number = containerWidth/containerHeight; var imageRatio:Number = imageWidth/imageHeight; if( imageRatio > containerRatio ) { bgImage.width = Math.floor(imageWidth*containerHeight/imageHeight); bgImage.height = containerHeight; } else { bgImage.height = Math.floor(imageHeight*containerWidth/imageWidth); bgImage.width = containerWidth; } Much appreciated! Greg On Tue, Sep 29, 2009 at 4:32 AM, dorkie dork from dorktown < dorkiedorkfromdorkt...@gmail.com> wrote: > > > Hi Greg, > > I'm not sure exactly what you are trying to do but if I understand > correctly you can do the following. You could make this into a component but > for testing do the following. > > Add a canvas to your application. Set it to the height and width you want. > Add an image component to it and anchor it to the vertical and horizontal > center. Do not set width or height. Set the images vertical and horizontal > align to middle and center. Set the source of the image. Run the > application. Go back to the Flash Builder. > > Check when the image has loaded, add an event.complete handler. When you > get that you'll have the width and height of the image. Now, either set the > container to the width and height or scale the image up by either by > increasing the scaleX, scaleY or setting the width OR height to the width > and or height of the container. > > I would add a width and height slider and a scaleX and scaleY slider next > to the canvas so you can test it. > > You'll have to tweak this obviously. Investigate the maintainAspectRatio > property on the Image class, the clipContent property and the other > properties on the Image class. > > dorkie image wrangling dork from dorktown > > > > On Mon, Sep 28, 2009 at 3:31 PM, Greg Hess <flexeff...@gmail.com> wrote: > >> >> >> Hi All, >> >> I have a content area that I need to fill with a user supplied >> graphic. The graphic may be any aspect ratio and I want to scale the >> image to the content area and maintain aspect ratio however, instead >> of producing "white" space where the aspect ratio could not be >> achieved(Standard behavior of the Image class) I would like to clip >> the image. The area will always be filled entirely, the aspect ratio >> will be maintained but the image may be clipped. >> >> Does anyone know how I can do this? >> >> Any help much appreciated. >> >> Greg >> > > >