I have created a photo gallery that loads images into a movie clip via an xml document. By default the movie clip is sized for landscape images but if I load a portrait image it loads on the left of the movie clip. How can I get it to load centrally?
Code:
var my_xml = new XML();
my_xml.ignoreWhite = true;
PhotoPath = newPath;
PhotoFile = newFile;
Photonr = 0;
fadeSpeed = 30;
my_xml.onLoad = function(success) {
if (success) {
_global.file = [];
_global.description = [];
_global.photonr = 0;
for (var i=0; i<my_xml .firstChild.childNodes.length; i++) {
_global.file[i] = my_xml.firstChild.childNodes[i].attributes.file;
_global.description[i] = my_xml.firstChild.childNodes[i].attributes.description;
}
_global.TotalNum = i;
loadMovie(PhotoPath+"/"+_global.file[Photonr],photo);
dynText.text=_global.description[Photonr];
}
};
changePhoto = function(direct) {
MaxPhoto = _global.TotalNum - 1;
if (direct==-1) {
switch(Photonr) {
case 0:
Photonr = MaxPhoto;
break;
default:
Photonr = Photonr - 1;
}
} else {
switch(Photonr) {
case MaxPhoto:
Photonr = 0;
break;
default:
Photonr = Photonr + 1;
}
}
onEnterFrame = fadeOut;
};
fadeOut = function() {
if (photo._alpha>fadeSpeed) {
photo._alpha -= fadeSpeed;
frame._alpha -= fadespeed;
} else {
loadPhoto();
}
};
loadPhoto = function() {
loadMovie(PhotoPath+"/"+_global.file[Photonr],photo);
dynText.text=_global.description[Photonr];
onEnterFrame = loadMeter;
};
loadMeter = function() {
var l, t;
l = photo.getBytesLoaded();
t = photo.getBytesTotal();
if (t>0 && t == l) {
onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
fadeIn = function() {
if (photo._alpha<100-fadeSpeed) {
photo._alpha += fadeSpeed;
} else {
photo._alpha = 100;
onEnterFrame = null;
}
};
my_xml.load(newFile);