Scale Move Clip resizeListener(null); on Page load

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<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(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);