Had some issues with the Image too, use an
<mx:Image ... complete="{centerImage()}" />
The complete was the one method that seemed to fire when the image was
loaded.
Good Luck.
LD
--- In [email protected], Russell Sprague <[EMAIL PROTECTED]> wrote:
>
> well that is what I thought, but I couldn't get it to work.
>
> Shannon Hicks wrote:
> >
> > You could always set the x/y by hand when you load the image.
> > Something like this:
> >
> > loadImage():void {
> > image.source = mynewimage.jpg
> > callLater(centerImage);
> > }
> >
> > centerImage():void {
> > image.x = (wrapper.width / 2) - (image.width / 2);
> > image.y = (wrapper.height/ 2) - (image.height/ 2);
> > }
> >
> > Shan
> >
> > Russell Sprague wrote:
> >
> >> @Matt
> >> yea I don't really hate the docs, I was just a little frustrated,
> >> because most of the examples are Actionscript examples, and if I am
> >> looking for an example of how to do something in mxml, I don't know
> >> enough to translate the AS to mxml.
> >>
> >> @roman
> >> I tried the horizontal and verticalCenter, and it didn't work
> >> I think part of the problem is there is nothing in the component
> >> until I load the image, so there is nothing to measure to.
> >>
> >> Russ
> >> Matt Horn wrote:
> >>
> >>> > I hate the flex documentation...
> >>>
> >>> Also, if there are specific problems with the documentation,
please let
> >>> the doc team know by either posting to this list, adding a
comment to
> >>> livedocs, or filing a bug at http://www.adobe.com/go/wish.
> >>> <http://www.adobe.com/go/wish.> Thanks,
> >>>
> >>> matt horn
> >>> flex docs
> >>>
> >>> > -----Original Message-----
> >>> > From: [email protected]
> >>> <mailto:flexcoders%40yahoogroups.com>
> >>> > [mailto:[email protected]
> >>> <mailto:flexcoders%40yahoogroups.com>] On Behalf Of Roman Protsiuk
> >>> > Sent: Thursday, January 18, 2007 7:51 AM
> >>> > To: [email protected]
<mailto:flexcoders%40yahoogroups.com>
> >>> > Subject: Re: [flexcoders] It shouldn't be this hard.
> >>> >
> >>> > 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]
> >>> <mailto:rsprague%40infusion-studios.com>
> >>> > <mailto:[EMAIL PROTECTED]
> >>> <mailto:rsprague%40infusion-studios.com>> > 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
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>>
> >>
> >
> >
>