# Strange Resize Problem

**URL:** <https://forum.kirupa.com/t/strange-resize-problem/269431>\
**Category:** flash\
**Created:** [August 27, 2008, 3:18pm UTC](https://forum.kirupa.com/t/strange-resize-problem/269431 "2008-08-27T15:18:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rundevo](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@Rundevo](https://forum.kirupa.com/u/Rundevo)\
**Post date:** [August 27, 2008, 3:18pm UTC](https://forum.kirupa.com/t/strange-resize-problem/269431/1 "2008-08-27T15:18:16Z")

</div>

Hi guys!  
Got a strange problem thats driving me crazy, so I really hope someone can help me out!

I´m trying to center a swf within a swf, never been a problem before, here´s the code!

```auto
var container:Sprite;
container = new Sprite();	

stage.addChild(container);
var url:URLRequest = new URLRequest("rl.swf");
var loader:Loader = new Loader();
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
			
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
		
function completeHandler(event:Event):void
{			
	container.addChild(event.target.content);
	container.x = stage.stageWidth/2 - container.width /2;
	container.y = stage.stageHeight/2 - container.height /2;
	trace(container.width);
	trace(container.height);
			
	stage.addEventListener(Event.RESIZE, resizeHandler);
}
		
function resizeHandler(event:Event):void
{
	container.x = stage.stageWidth/2 - container.width /2;
	container.y = stage.stageHeight/2 - container.height /2;
	trace(container.width);
	trace(container.height);
}

```

Everything works out as long as I dont load any external object to the swf that I´m trying to center!  
The completeHandler function does what its supposed to, but the resizeHandler function does not and I´m getting different values in the trace statement when I resize the window even though the functions are exactly the same, to me anyways.

Have I missed something with the eventlistener on the stage when I have externally loaded files present? Because the resizeHandler function works when I dont load the images.

Any help in this matter would be so very appreciated!

Thanks  
/rundevo
