title: Dynamic stageWidth and Height in Flash AS3
body: <p>This seems like it would be a really easy thing to do, but its been giving me all kinds of headaches.  I have a movieclip that is a gallery, It's linked to be called from AS when a button is clicked.  When an image in the gallery is clicked, It fades in using the Tween class and is <em>supposed</em> to be centered in the main stage, but its centering to the movieClip instead.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>//Centers and places image right ondo the display board
  function fullLoaded(e:Event):void {
      var myFull:Loader = Loader(e.target.loader);
      addChild(myFull);
  
      //positioning
      myFull.x = (stage.stageWidth - myFull.width) / 2;
      myFull.y = (stage.stageHeight - myFull.height) /2;
  
      //register the remove function
      myFull.addEventListener(MouseEvent.CLICK, removeFull);
  
      new Tween(myFull, "alpha", Strong.easeInOut,0,1,0.5,true);
  }
  </code></pre>
  
  <p>I have tried all of these combinations to no avail:</p>
  
  <pre><code>MovieClip(root).stage.stageWidth  
  root.stage.stageWidth  
  parent.stage.stageWidth
  </code></pre>
  
  <p>None of these place the image in the right spot.</p>