title: Flex3: How can I make a container resize based on the size of its contents?
body: <p>FYI, I'm a Flex newbie.</p>
  
  <p>I'm trying to create a Flex application that can automatically shrink based on the size of the components that it contains, so that a user can shrink it to a minimal view to see more of the HTML page it's embedded in.</p>
  
  <p>I know how to change the size of the whole application using ExternalInterface, but I'm having trouble automatically figuring out how much the size changed when something is hidden or shown.</p>
  
  <p>For example:</p>
  
  <p>Let's say I have the following flex layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"&gt;
          &lt;mx:VBox width="100%" paddingTop="0" paddingBottom="0"
                  paddingLeft="0" paddingRight="0" horizontalGap="0" id="mainVBox"&gt;
               &lt;mx:HBox&gt;            
                   &lt;mx:Button label="hide-show b" click="{showHideB()}"/&gt;
               &lt;/mx:HBox&gt;
  
               &lt;mx:Text id="a" text="a" fontSize="42" textAlign="center"/&gt;
               &lt;mx:Text id="b" text="b" fontSize="42" textAlign="center"/&gt;
  
       &lt;/mx:VBox&gt;
   &lt;/mx:Application&gt;
  </code></pre>
  
  <p>How can I hide one of the text fields and cause the VBox to shrink?  I'm currently setting it to visible = false, but that doesn't seem to affect the parent VBox.</p>
  
  <p>Once the VBox shrinks, how can I detect that the Application no longer needs so much space, and then go about figuring out how much less space it needs?</p>
  
  <p>I've tried using ResizeEvent, but I haven't been able to get them to work, but I could be doing something wrong.</p>
  
  <p>Thanks!</p>