# External SWF Scaling Issue Relating to Window Resize

**URL:** https://forum.kirupa.com/t/external-swf-scaling-issue-relating-to-window-resize/309725
**Category:** flash
**Created:** [May 23, 2010, 6:05am UTC](https://forum.kirupa.com/t/external-swf-scaling-issue-relating-to-window-resize/309725 "2010-05-23T06:05:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![matrixm5](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@matrixm5](https://forum.kirupa.com/u/matrixm5)
#### Post date: [May 23, 2010, 6:05am UTC](https://forum.kirupa.com/t/external-swf-scaling-issue-relating-to-window-resize/309725/1 "2010-05-23T06:05:57Z")

</div>

Hello All,

I am trying to scale external swfs to the window size that exists at the point when the button is clicked. The external swf is being loaded into a dynamically created mc in the main swf. I am using a resize handler and the issue i am having is that all external swfs only become veiwable when the window is resized. After the window is resized, they become viewable and scale on the resizing of the window. I call the resize handler to upate the scale base on the window size but to no avail.

The AS (3.0) that I am using can be seen below. Any help would be greatly appreciated.

stop();

var Xpos:Number = 0;  
var Ypos:Number = 0;  
var defaultSWF:URLRequest = new URLRequest(“test.swf”);  
var loader:Loader = new Loader ();  
loader.x = Xpos;  
loader.y = Ypos;  
loader.load(defaultSWF);  
addChild(loader);

menu\_mc.about\_btn.addEventListener(MouseEvent.CLICK,aboutClick);

function aboutClick(e:MouseEvent):void {

```
removeChild(loader);
var about:URLRequest = new URLRequest("demo1.swf");
loader.load(about);
addChild(loader);
loader.x = Xpos;
loader.y = Ypos;
trace ("click");
resizeHandler();

```

}

//  
// Resize Handler  
//

stage.align = StageAlign.TOP\_LEFT;  
stage.scaleMode = StageScaleMode.NO\_SCALE;

stage.addEventListener( Event.RESIZE, resizeHandler);

function resizeHandler( e:Event=null ):void  
{  
var w:Number = stage.stageWidth;  
var h:Number = stage.stageHeight;

```
loader.x = (w-loader.width)/2;
loader.y = (h-loader.height)/2;

if (stage.width/stage.height&gt;loader.width/loader.height) {
	
	loader.width = w;
	loader.scaleY = loader.scaleX;
}else{
	 loader.height = h;
                       loader.scaleX = loader.scaleY;
}

```

}
