title: Why does obj.getBounds().height give a larger height than obj.height?
body: <p>I'm new to Flash and ActionScript, but managing quite nicely. One thing that is continuously getting in my way are the <code>width</code> and <code>height</code> properties of <code>DisplayObject(Container)</code>s. I'm finally starting to get my head around them and learned that the width and height of a <code>Sprite</code> are determined solely by their contents for example.</p>
  
  <p>I do not understand the following though: I've got a <code>Sprite</code> that I add a bunch of <code>Button</code>s to. The buttons all have a <code>height</code> of 30 and an <code>y</code> of 0. As such, I'd expect the <code>height</code> of the containing <code>Sprite</code> to be 30. Surprisingly, the <code>height</code> is 100.</p>
  
  <p>The Adobe documentation of the <code>height</code> property of a <code>DisplayObject</code> states:</p>
  
  <blockquote>
    <p>Indicates the height of the display object, in pixels. The height is calculated based on the <strong>bounds</strong> of the content of the display object.</p>
  </blockquote>
  
  <p>Apparently, the 'bounds' of the object are important. So I went ahead and wrote this little test in the <code>Sprite</code> that contains the <code>Button</code>s:</p>
  
  <pre><code>for (var i:int = 0; i &lt; numChildren; ++i)
  {
      trace("Y: " + getChildAt(i).y + " H: " + getChildAt(i).height);
      trace("BOUNDS H: " + getChildAt(i).getBounds(this).height);
  }
  trace("SCALEY: " + scaleY + " TOTAL HEIGHT: " + height);
  </code></pre>
  
  <p>This code iterates through all the objects that are added to its display list and shows their <code>y</code>, <code>height</code> and <code>getBounds().height</code> values. Surprisingly, the output is:</p>
  
  <pre><code>Y: 0 H: 30
  BOUNDS H: 100
  ... (5x) 
  SCALEY: 1 TOTAL HEIGHT: 100
  </code></pre>
  
  <p>This shows that the bounds of the buttons are actually larger than their height (and the height that they appear to be, visually). I have no clue why this is the case however. So my questions are:</p>
  
  <ul>
  <li>Why are the bounds of my buttons
  larger than their height?  </li>
  <li>How can I
  set the bounds of my buttons so that
  my <code>Sprite</code> isn't larger than I'd
  expect it to be based on the
  position and size of the objects it
  contains?</li>
  </ul>
  
  <p>By the way, the buttons are created as follows:</p>
  
  <pre><code>var control:Button = new Button();
  control.setSize(90, 30);
  addChild(control);
  </code></pre>