1 Reply Latest reply on Feb 2, 2011 12:02 PM by Pablo Souza

    Smart sizing when dropping a custom component into a Container...

    peteandrus

      so, if i create a custom component with a List, CheckBox and a button (the custom component itself is a s:Group), how can i tell it to resize itself to fit anything i then drop it into?

       

      For instance, i created a component with the above mentioned children.When i drop it into a BorderedContainer, it ends up being bigger than the container, and when i resize the entire object i only end up resizing the 'Border' object, but the LIst and CheckBox and everything else stays the same, so it screws me up.

       

      does any of this make sense? anybody know how to fix this?

       

      thanks!

        • 1. Re: Smart sizing when dropping a custom component into a Container...
          Pablo Souza Level 3

          Hi Pete!

           

          Flex provides some ways to control the size of containers and controls: default sizing, explicit sizing, percentage-based sizing and contraint-based layout.

           

          If you have your custom component getting bigger than the BorderContainer try using one of these mechanisms like contraint-based layout. See code after the jump.

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application
               xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx">
                    
               <s:Group left="10" top="10" right="10" bottom="10">
                    <s:BorderContainer left="10" top="10" right="10" bottom="10">
                         <s:TextArea left="10" top="10" right="10" bottom="10">
                         </s:TextArea>
                    </s:BorderContainer>
               </s:Group>
               
          </s:Application>

           

           

          Hope it helps!

           

           

          Best regards,

          Pablo Souza