Tile background problem

Hi Guys

i have tried to do tile background, and I also created a listener so it can fit in any screen but somehow it doesn’t really work when I resize the window.

can anyone tell me the reason?
Thanks

stop();
Stage.scaleMode = “noscale”;
Stage.align = “tl”;

sizeListener = new Object();
sizeListener.onResize = doResize;
Stage.addListener({onResize:doResize});

function doResize() {
tile_width = 34;
tile_height = 34;
//
x_max = Math.round(Stage.width/tile_width);
y_max = Math.round(Stage.height/tile_height);
trace(x_max);
trace(y_max);
for (x=0; x<x_max; x++) {
for (y=0; y<y_max; y++) {
bg = _root.attachMovie(“square”, “bg”+x+y, this.getNextHighestDepth());
bg._x = tile_widthx;
bg._y = tile_height
y;
}
}
};
Stage.addListener(sizeListener);
doResize();