Full Browser not working with addChild

Full Browser not working with addChild

Hi all

I’m working on a full browser site - it has 3 MovieClips, header_mc, body_mc and footer_mc.

When the browser resizes, the header and footer stay the same height and the body height changes.

It’s all working fine when I have the MovieClips on the stage and named.

http://www.ttmt.org.uk/imgScale/1/


stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
//
//--Page Structure------------------------

var footerH:Number=170;
var headerFooterH:Number=250;

stage.addEventListener(Event.RESIZE, stage_resizeHandler);

function stage_resizeHandler(evt:Event):void {
	resizeWindow();
}

function resizeWindow() {
	var stageW:Number=stage.stageWidth;
	var stageH:Number=stage.stageHeight;
	header_mc.width=body_mc.width=footer_mc.width=stageW;
	body_mc.height=stageH-headerFooterH;
	footer_mc.y=stageH-footerH;
}

But if I try to add the MovieClip at run time it doesn’t work - does anyone know or see why it won’t work.

http://www.ttmt.org.uk/imgScale/2/


stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
//
//--Page Structure------------------------
var header_mc:MovieClip = new MovieClip();
var body_mc:MovieClip = new MovieClip();
var footer_mc:MovieClip = new MovieClip();
//
var pageW:Number=1670;
var headH:Number=80;
var bodyH:Number=700;
var footerH:Number=170;
var headerFooterH:Number=250;
//
function createStructure(clip, col, xpos, ypox, wid, het):void {
	clip.graphics.beginFill(col);
	clip.graphics.drawRect(xpos,ypox,wid,het);
	clip.graphics.endFill();
	addChild(clip);
}
//
createStructure(header_mc, 0x009999,0,0,pageW, headH);
createStructure(body_mc, 0x8C650D,0,80,pageW, bodyH);
createStructure(footer_mc, 0x12871E,0,780,pageW, footerH);
//
stage.addEventListener(Event.RESIZE, stage_resizeHandler);

function stage_resizeHandler(evt:Event):void {
	resizeWindow();
}

function resizeWindow() {
	var stageW:Number=stage.stageWidth;
	var stageH:Number=stage.stageHeight;
	header_mc.width=body_mc.width=footer_mc.width=stageW;
	body_mc.height=stageH-headerFooterH;
	footer_mc.y=stageH-footerH;
}