# Scale Move Clip resizeListener(null); on Page load

**URL:** <https://forum.kirupa.com/t/scale-move-clip-resizelistener-null-on-page-load/295877>\
**Category:** flash\
**Created:** [September 6, 2009, 4:07pm UTC](https://forum.kirupa.com/t/scale-move-clip-resizelistener-null-on-page-load/295877 "2009-09-06T16:07:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alucardac](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@alucardac](https://forum.kirupa.com/u/alucardac)\
**Post date:** [September 6, 2009, 4:07pm UTC](https://forum.kirupa.com/t/scale-move-clip-resizelistener-null-on-page-load/295877/1 "2009-09-06T16:07:25Z")

</div>

Hi there, So I’ve built a photo gallery that resizes with the window browser. The only problem is that when I first open up the window the gallery is not properly scaled to fit the window size. I was given a tip that when you place [COLOR=“Red”]resizeListener(null);[/COLOR] in the code. This worked, but the only problem is that the image scales disproportionately when the window loads. I’ve noticed that when I tinker around with some of the code [COLOR=“Red”](highlighted in RED below)[/COLOR] it effects this, but I have not figured out how to resolve it.

import gs._;  
import fl.transitions._;  
import fl.transitions.Tween;  
import fl.transitions.easing.\*;  
import flash.display.StageAlign;  
import flash.display.StageScaleMode;  
import flash.events.Event;  
stage.align=StageAlign.TOP\_LEFT;  
stage.scaleMode=StageScaleMode.NO\_SCALE;  
stage.dispatchEvent(new Event(Event.RESIZE));  
var wTween:Tween;  
var hTween:Tween;

//GREEN SOCK  
//Code to center the gallery and scale it with the window size  
stage.addEventListener(Event.RESIZE, resizeListener);  
function resizeListener(e:Event):void {  
var startWidth:int=gallery.width;  
var startHeight:int=gallery.height;  
var startX:int=gallery.x;  
var startY:int=gallery.y;

```
gallery.width=stage.stageWidth-40;
gallery.height=stage.stageHeight-40;

[COLOR="red"]//THIS SEEMS TO BE THE PROBLEM
if (gallery.scaleX&lt;gallery.scaleY) {
	gallery.scaleY=gallery.scaleX;
} else {
	gallery.scaleX=gallery.scaleY;
}

```

[/COLOR]

```
gallery.x = (gallery.stage.stageWidth / 2) - (gallery.width / 2);
gallery.y = (gallery.stage.stageHeight / 2) - (gallery.height / 2);

TweenLite.from(gallery, .5, {width:startWidth, height:startHeight, x:startX, y:startY});

```

}

//Makes images load at gallery size  
[COLOR=“Red”]resizeListener(null);[/COLOR]  
trace(“width=”+ gallery.width);  
trace(“height=”+ gallery.height);

//smoothing

function loadProdComplete(e:Event):void {

```
var bit:Bitmap=e.target.content;
if (bit!=null) {
	bit.smoothing=true;
}
gallery.addChild(e.target.content);

```

}

function loadImage(event: MouseEvent):void {  
i++;// this adds 1 to our index variable  
if (i\>=images.length) {  
i=0;  
}  
trace("Index: "+i);  
loader.load(new URLRequest(images\*));  
trace("Image: " + images\*);  
[//stage.dispatchEvent](https://stage.dispatchEvent)(new Event(Event.RESIZE));  
}

// VARIABLES  
var loader = new Loader();  
var i:int=0;  
var images:Array = new Array(  
“1.jpg”,  
“2.jpg”,  
“3.jpg”  
);

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);  
loader.load(new URLRequest(images\*));  
gallery.addEventListener(MouseEvent.CLICK, loadImage);
