# Reposition gallery when window is resized, see code / HELP!

**URL:** <https://forum.kirupa.com/t/reposition-gallery-when-window-is-resized-see-code-help/63293>\
**Category:** Uncategorized\
**Created:** [September 4, 2004, 10:38pm UTC](https://forum.kirupa.com/t/reposition-gallery-when-window-is-resized-see-code-help/63293 "2004-09-04T22:38:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![freddie](https://avatars.discourse-cdn.com/v4/letter/f/a87d85/32.png) [@freddie](https://forum.kirupa.com/u/freddie)\
**Post date:** [September 4, 2004, 10:38pm UTC](https://forum.kirupa.com/t/reposition-gallery-when-window-is-resized-see-code-help/63293/1 "2004-09-04T22:38:31Z")

</div>

there is a code that will reposition to the center of stage when window is maximized etc. problem is i dont know how to incorporate into the gallery.

please someone look at the code and please help!

```auto
 
mainListener = new Object();
mainListener.onResize = function() {
_root.containerMC.pos = [Stage.width/2-_root.containerMC._width/2, Stage.height/2-_root.containerMC._height/2];
};
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener(mainListener);
_root.containerMC.onEnterFrame = function() {
this._x += (this.pos[0]-this._x)/6;
this._y += (this.pos[1]-this._y)/6;
border._x = this._x;
border._y = this._y;
};

```

you can see my full code here, it is working but it stops and then nothing, and it wont reposition right away to the center… and border is not moving with it…

please help!!!

```auto
spacing = 10;
containerMC._alpha = 0;
MovieClip.prototype.loadPic = function(pic) {
_root.containerMC._alpha = 0;
this.loadMovie(pic);
_root.onEnterFrame = function() {
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
if (t != 0 && Math.round(l/t) == 1) {
var w = containerMC._width+spacing, h = containerMC._height+spacing;
mainListener = new Object();
mainListener.onResize = function() {
	_root.containerMC.pos = [Stage.width/2-_root.containerMC._width/2, Stage.height/2-_root.containerMC._height/2];
};
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener(mainListener);
_root.containerMC.onEnterFrame = function() {
	this._x += (this.pos[0]-this._x)/6;
	this._y += (this.pos[1]-this._y)/6;
	border._x = this._x;
	border._y = this._y;
};
border.resizeMe(w, h);
delete _root.onEnterFrame;
}
};
};
MovieClip.prototype.resizeMe = function(w, h) {
var speed = 3;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
if (Math.abs(this._width-w)<1) {
this._width = w;
this._height = h;
_root.containerMC._x = this._x-this._width/2+spacing/2;
_root.containerMC._y = this._y-this._height/2+spacing/2;
_root.containerMC._alpha += 5;
if (_root.containerMC._alpha>90) {
	_root.containerMC._alpha = 100;
	delete this.onEnterFrame;
}
}
};
};

```

=) thanks
