The problem is that flex is asynchronous. At the time you invoke the move method, flex doesn't still know the image size. Trying using a listener for the Complete event of the Image. There you'll be able to invoke the move method.

Best
X.

On 10/9/06, Greg Morphis <[EMAIL PROTECTED]> wrote:
Why is this so freaking hard?
This is insane.. Create the image, set the source property and then
move it to the center of the stage..
And it's not working!?

        <mx:Script>
                <![CDATA[
                        import mx.controls.Image;
                        import mx.controls.Alert;
                        public function init():void
                        {
                                var icon1:Image = new Image();
                                var icon2:Image = new Image();
                                icon1.source = "img/icon1.jpg";
                                icon2.source = "img/icon2.jpg";

                                can.addChild(icon1);
                                can.addChild(icon2);

                                //icon1.x = can.width - icon1.width;
                                //icon1.y = can.height - icon1.height;

                                //icon2.x = icon1.x;
                                //icon2.y = icon1.y + icon1.height + 20;

                                icon1.move((can.width - icon1.width)/2,(can.height - icon1.height)/2 );
                                icon2.move((can.width - icon2.width)/2,((can.height -
icon2.height)/2)+ icon2.height + 20 );

                                //icon2.cacheAsBitmap = true;
                                //icon1.cacheAsBitmap = true;


                        }
                ]]>
        </mx:Script>


What am I doing wrong and why does Flex have to be an ass about it?


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED]
    mailto: [EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to