Image resizing/fixed position for larger images

Hello all.

I have decided to play around with Flash and try and teach myself something. Now I have done kirupa.com - XML and Flash Photogallery, Page 1 this tutorial, as well as the other tutorial to add a scrolling thumbnails element to it with no problems at all.

I have (using the code provided by Cello in his resize.zip found here kirupaForum) made it so images of any size can be used. From this, how would i make it so rather then eh top left of each image being loaded, the center of each image is loaded. This way all pictures will have their position in the same location?

I have changed the layout and everything to accommodate the larger sizes, and right now i have started from scratch so i do not have the scrolling thumbnail element included.

here is the code.

function loadXML(loaded) {

if (loaded) {

xmlNode = this.firstChild;
image = ;
description = ;
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {

image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;

}
firstImage();

} else {

content = “file not loaded!”;

}

}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“images.xml”);
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {

if (Key.getCode() == Key.LEFT) {

prevImage();

} else if (Key.getCode() == Key.RIGHT) {

nextImage();

}

};
Key.addListener(listen);
previous_btn.onRelease = function() {

prevImage();

};
next_btn.onRelease = function() {

nextImage();

};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {

filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {

preloader.preload_bar._xscale = 100*loaded/filesize;

} else {

preloader._visible = false;
if (picture._alpha<100) {

picture._alpha += 10;

}

}

};
function nextImage() {

if (p<(total-1)) {

p++;
if (loaded == filesize) {
spacing = 10;
picture._alpha = 0;

MovieClip.prototype.loadPic = function(pic){
_root.picture._alpha = 0;
this.loadMovie(pic);
_root.onEnterFrame = function(){
var t = picture.getBytesTotal(), l = picture.getBytesLoaded();
if (t != 0 && Math.round(l/t) == 1){
var w = picture._width + spacing, h = picture._height + spacing;
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.picture._x = this._x - this._width/2 + spacing/2;
_root.picture._y = this._y - this._height/2 + spacing/2;
_root.picture._alpha = 100;
delete this.onEnterFrame;
}
}
};
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();

}

}

}
function prevImage() {

if (p>0) {
spacing = 10;
picture._alpha = 0;

MovieClip.prototype.loadPic = function(pic){
_root.picture._alpha = 0;
this.loadMovie(pic);
_root.onEnterFrame = function(){
var t = picture.getBytesTotal(), l = picture.getBytesLoaded();
if (t != 0 && Math.round(l/t) == 1){
var w = picture._width + spacing, h = picture._height + spacing;
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.picture._x = this._x - this._width/2 + spacing/2;
_root.picture._y = this._y - this._height/2 + spacing/2;
_root.picture._alpha = 100;
delete this.onEnterFrame;
}
}
};
p–;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();

}

}
function firstImage() {

if (loaded == filesize) {

picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();

}

}
function picture_num() {

current_pos = p+1;
pos_txt.text = current_pos+" / "+total;

}

If my logic is wrong it would be great if you guys could let me know seeing as this is my first time with flash. Thanks.

Any help would be great.

I have tired looking at examples here kirupaForum but all links seem to be expired.

and here

Thank you all