Need help with AS3 stage resize and position MovieClip

I have never been so F*#$in confused and frustrated since I upgraded to CS3. Making what I need to do make would be so easy if I was using AS2 but the transition from AS2 to AS3 hasn’t been easy to say the least.

Im trying to create a class that allows me to specify two MovieClips stored in the library and have one of them stretch the same width and height as the stage and the other be centered according to the stage dimentions.

For example:


// this = reference to the stage, it might not be needed?
// backgroundClip = reference to the clip that is stretched
// centerClip = reference to the clip that is centered
new StageResize(this, backgroundClip, centerClip);

I started building the class but it doesn’t actualy doing anything at the moment because I realised half way through that I would need to attach the MovieClips to the stage somehow using the names specified. I read that attachMovie has been thrown out in AS3 so how can this be done?

something like below?

 
var centerMC:MovieClip = new theMovieClip(); // theMovieClip is in the library
this.addChild(centerMC); // attach it to the stage

If what I’ve said makes sense to you, now is you chance to speak up and lend a hand.
Thanks in advance.

 
package com.adyson {
 
 // Import all the classes that are needed
 import flash.display.Sprite;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import flash.events.Event;
 public class StageResize {
 
  // The movielcips to be centered and stretched
  private var _targetArea:MovieClip; // this
  private var _targetCent:MovieClip; // clip to be centered
  private var _targetBack:MovieClip; // stretched background
 
  public function StageResize(targetArea:MovieClip, targetCent:MovieClip, targetBack:MovieClip) {
 
   this._targetArea = targetArea;
   this._targetCent = targetCent;
   this._targetBack = targetBack;
 
   // Stage scalemode and position
   stage.align = StageAlign.TOP_LEFT;
   stage.scaleMode = StageScaleMode.NO_SCALE;
 
   // Event listeners
   stage.addEventListener(Event.ACTIVATE, activateHandler);
   stage.addEventListener(Event.RESIZE, resizeHandler);
  }
  private function activateHandler(event:Event):void {
   //
  }
  private function resizeHandler(event:Event):void {
 
   _targetCent.x = stage.stageWidth / 2 - _targetCent.width / 2;
   _targetCent.y = stage.stageHeight / 2 - _targetCent.height / 2;
   _targetBack.width = stage.stageWidth;
   _targetBack.height = stage.stageHeight;
 
  }
 }
}