# Centered xml images / centered onResize

**URL:** <https://forum.kirupa.com/t/centered-xml-images-centered-onresize/169279>\
**Category:** Uncategorized\
**Created:** [November 14, 2005, 11:40pm UTC](https://forum.kirupa.com/t/centered-xml-images-centered-onresize/169279 "2005-11-14T23:40:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rynobot](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@rynobot](https://forum.kirupa.com/u/rynobot)\
**Post date:** [November 14, 2005, 11:40pm UTC](https://forum.kirupa.com/t/centered-xml-images-centered-onresize/169279/1 "2005-11-14T23:40:23Z")

</div>

I am loading xml images, while also trying to center them onResize.

In this tutorial: [http://www.kirupa.com/developer/mx2004/xml\_flash\_photogallery.htm](http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm) the images are all the same size, are being loaded into a static movieclip, and are aligned to the Top Left corner.

What I am trying to do is load different size images into a movie clip which stays centered on resize (i’m making a fullscreen flash site), while also loading each individual image centered within that clip (instead of the default top left).

Here is the code I am using for postioning the MC onResize:

```auto
mainInit();
function mainInit() {
	// Set alignment and scale to allow onResize to work.
	//Stage.align = "LT";
	//Stage.scaleMode = "noScale";
	// Create the title clip.
	this.attachMovie("picture", "picture", 10);
	// Keeps the title clip in place when the movie is resized.
	picture.onResize = function() {
		this._y = Stage.height-(picture._height/2);
		this._x = Stage.width-(picture._width/2);
	};
	// Register titleClip to be notified when movie is resized.
	Stage.addListener(picture);
	// Set initial position of title clip.
	this.picture.onResize();
}

```

I tested the following code (given to me by ‘The Canadian’ - thanks!) - within the xml onload function using that tutorial and it would not work with the first image, and seemed to only work properly 90% of the time:

```auto
picture._x = (Stage.width / 2) - (picture._width / 2);
picture._y = (Stage.height / 2) - (picture._height / 2);

```

…So, my question is does anyone know how to load center aligned variable size images, while also calling the movieclip to center onResize. I have tried everything I can think of and cannot get it working properly…
