The first thought is:

<mx:Canvas width="100%" height="100%">
   <mx:Image source="{yourSource}" horizontalCenter="0" verticalCenter="0"
/>
</mx:Canvas>

To scale, dunno, but maybe something like:

<mx:Canvas id="imageContainer" width="100%" height="100%">
   <mx:Image id="image"
       source="{yourSource}"
       width="{imageContainer.width < image.width ? imageContainer.width :
image.width}"
       height="{imageContainer.height < image.height ?
imageContainer.height : image.height}"
       scaleContent="true"
       horizontalCenter="0"
       verticalCenter="0" />
</mx:Canvas>

This one probably won't work, it's very dirty, however might give you a
clue... ;)

And the easiest way to scale, but still, not so nice from the point of ui
(it scales both way) is just:

<mx:Image source="{yourSource}" scaleContent="true" width="100%"
height="100%" />

Have fun,
R.


On 1/18/07, Russell Sprague <[EMAIL PROTECTED]> wrote:

  I hate the flex documentation...

All I want to do is dynamically center an image on my stage.

I have a VDividedBox with an image in the top, and text in the bottom.
I loading in images by setting the source of an image tag(probably not
the best way to do it, but again I hate the Flex docs...).
So when the image loads I am trying to set it to center in the upper
pane of the vdividedbox, but all my attemps have failed.

It would be nice to also resize the image as the divideBar is dragged,
but only to the original size of the image, then it just centers.

Thanks
Russ

Reply via email to