5 Replies Latest reply on Feb 27, 2009 5:36 AM by Newsgroup_User

    Flex Box container issue

    drnathan82
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.controls.Image;
      import mx.controls.Alert;
      public var img:Image = new Image();
      public function GetSize():void{
      Alert.show(cont.getChildAt(0).width.toString());
      }

      public function LoadImage():void{
      img.source= ' http://localhost/compile.php.jpg';
      img.width =100.99;
      img.height =200.99;
      cont.addChild(img);
      }
      ]]>
      </mx:Script>
      <mx:Box id= "cont" >
      </mx:Box>
      <mx:Button x="28" y="325" label="LoadImage" click="LoadImage()"/>
      <mx:Button x="158" y="325" label="GetSize" click="GetSize()"/>
      </mx:Application>

      The above application returns image's width and hieght as 100X200.
      How do we get the actual dimention (100.99 X 200.99) by using Box container?
        • 1. Re: Flex Box container issue
          Cesare Rocchi Level 2
          To specify how many digits after the decimal point use

          Alert.show(cont.getChildAt(0).width.toFixed(2));

          I think that, when set, width gets rounded, cause the code above
          returns "100.00".

          HTH.
          • 2. Re: Flex Box container issue
            Level 7

            "drnathan82" <webforumsuser@macromedia.com> wrote in message
            news:go5c7f$6ko$1@forums.macromedia.com...
            > <?xml version="1.0" encoding="utf-8"?>
            > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            > layout="absolute">
            > <mx:Script>
            > <![CDATA[
            > import mx.controls.Image;
            > import mx.controls.Alert;
            > public var img:Image = new Image();
            > public function GetSize():void{
            > Alert.show(cont.getChildAt(0).width.toString());
            > }
            >
            > public function LoadImage():void{
            > img.source= ' http://localhost/compile.php.jpg';
            > img.width =100.99;
            > img.height =200.99;
            > cont.addChild(img);
            > }
            > ]]>
            > </mx:Script>
            > <mx:Box id= "cont" >
            > </mx:Box>
            > <mx:Button x="28" y="325" label="LoadImage" click="LoadImage()"/>
            > <mx:Button x="158" y="325" label="GetSize" click="GetSize()"/>
            > </mx:Application>
            >
            > The above application returns image's width and hieght as 100X200.
            > How do we get the actual dimention (100.99 X 200.99) by using Box
            > container?

            Are you sure it's not returning the width of your LoadImage button?


            • 3. Flex Box container issue
              drnathan82 Level 1
              Sure Amy.
              If the actual image size is 300 X 600 pixels, then image.width is showing as100 instead of 100.99
              Is it possible to get the actual display width (100.99)?
              Help me
              • 4. Re: Flex Box container issue
                Level 7

                "drnathan82" <renga@inbox.com> wrote in message
                news:go7q8v$a63$1@forums.macromedia.com...
                > Sure Amy.
                > If the actual image size is 300 X 600 pixels, then image.width is showing
                > as100.99
                > Is it possible to get the actual display width (100.99)?
                > Help me

                The point I am getting at is that you are displaying the width of the first
                child. Since you didn't use addChildAt(), but addChild, your image is _not_
                the first child, but the last.


                • 5. Re: Flex Box container issue
                  Level 7

                  "drnathan82" <renga@inbox.com> wrote in message
                  news:go7q8v$a63$1@forums.macromedia.com...
                  > Sure Amy.
                  > If the actual image size is 300 X 600 pixels, then image.width is showing
                  > as100.99
                  > Is it possible to get the actual display width (100.99)?
                  > Help me

                  P.S. There is no such thing as .99 px.