title: UIComponent seems to have "padding/margins" set (Flex 3 to Flex 4 migration issue?)
body: <p>I have a Flex application that has a single UIComponent, which contains a single Bitmap object. In Flex 3 everything was good. In Flex 4, the same code results in an offset of the children within the UIComponent that I don't understand.</p>
  
  <p>Here is the object tag of my .html file:</p>
  
  <pre><code>        &lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="320" height="480" id="MyId"&gt;
            &lt;param name="allowScriptAccess" value="sameDomain" /&gt;
            &lt;param name="allowFullScreen" value="false" /&gt;
            &lt;param name="movie" value="MyFlexApp.swf" /&gt;
            &lt;param name="quality" value="high" /&gt;
            &lt;param name="bgcolor" value="#ffff00" /&gt;
            &lt;embed allowScriptAccess="sameDomain" allowFullScreen="false" src="MyFlexApp.swf" quality="high" bgcolor="#ffff00" width="320" height="480" name="MyAppName" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /&gt;
          &lt;/object&gt;
  </code></pre>
  
  <p>Here is my .mxml file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!-- usingas/UsingCDATA.mxml --&gt;
  &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="init()" width="320" height="480" backgroundColor="#FF0000" styleName="plain"&gt;
    &lt;mx:Script&gt;
      &lt;![CDATA[
      import mx.core.UIComponent;
      import MyClass;
      public function init() : void
      {
              var s:UIComponent = new MyClass();
              addChild( s );
      }
      ]]&gt;
    &lt;/mx:Script&gt;
  &lt;/mx:Application&gt;
  </code></pre>
  
  <p>And here is MyClass.as:</p>
  
  <pre><code>public class MyClass extends UIComponent
  {
      ... &lt;snip&gt; ...
  
      screenBitmap = new Bitmap( screenBitmapData );
      addChildAt( screenBitmap, 0 );
      // screenBitmap.x = -160;
      // screenBitmap.y = -24;
      var t:TextField = new TextField();
      t.type = TextFieldType.INPUT;
      t.border = true;
      t.text = "hello";
      addChildAt( t, 1 );
  
      ... &lt;snip&gt; ...
  }
  </code></pre>
  
  <p>Note that the  tag has a yellow background color. I see that yellow background correctly filling hte 320x480 size of the .swf. And note that the Application has a red background color. Again, after a flash of yellow, I see that red background correctly filling the 320x480 size of the .swf, so I believe the Application itself is not offset.</p>
  
  <p>But what I'm seeing is that the screenBitmap object appears offset within the display. It's 24 pixels too low and 160 pixels to the right (so the left edge of the bitmap starts exactly half-way across the app's display rectangle). I don't understand where those offsets are coming from. In particular, I don't know if the MyClass object is offset within the Application object (i.e., as if the Application object has a "left padding" of 160 and a "top padding" of 24), or whether it's the MyClass object that has those paddings, which then apply to <em>its</em> children (the bitmap and the TextField). (I'm using "padding" here to mean something like a .css padding that Flex is somehow doing, even though I don't see mention of such a concept in the Flex docs.)</p>
  
  <p>By uncommenting the two lines</p>
  
  <pre><code>    // screenBitmap.x = -160;
      // screenBitmap.y = -24;
  </code></pre>
  
  <p>I can get the bitmap to display "correctly", but it's not correct because mouse events on the bitmap are then offset incorrectly. I could of course compensate for the shifts in the handling of the mouse events also, but I want to understand why the shift is happening, instead of just blindly compensating for it.</p>
  
  <p>Note that I also include a TextField object:</p>
  
  <pre><code>    var t:TextField = new TextField();
      t.type = TextFieldType.INPUT;
      t.border = true;
      t.text = "hello";
      addChildAt( t, 1 );
  </code></pre>
  
  <p>I did this just to make sure it wasn't anything funky about my bitmap object that was causing the shift. The text object gets the same shift, with its top left at 160, 24 within the overall .swf rectangle.</p>
  
  <p>As I say, I didn't get these offsets in Flex 3. I'm using the exact same code, just compiling with the Flex 4 SDK now.</p>
  
  <p>Any idea where the offsets are coming from?</p>