Hello all.
I have this script, which centers a picture or swf dynamicly with a XML file.
Though some Swf files (or pictures for that matter) don’t center/scale properly…
Can anyone spot the flaw to why it might be so?
delay = 5000;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
}
firstImage();
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
picture._alpha = 0;
picture.loadMovie(image[p],1);
slideshow();
resizer();
}
}
function resizer() {
ctrl.onEnterFrame = function() {
//if (picture._width) {
//_root.picwidth = picture._width+'x'+picture._height;
if (picture._width>=picture._maxWidth) {
if (picture._width>=picture._height) {
picture._xscale = (200/picture._width)*100;
picture._yscale = picture._xscale;
//picture._width = maxWidth;
//picture._yscale = picture._xscale;
} else {
picture._yscale = (250/picture._height)*100;
picture._xscale = picture._yscale;
//picture._height = maxHeight;
//picture._xscale = picture._yscale;
picture._x = (Stage.width/2-picture._width/2);
picture._y = (Stage.height/2-picture._height/2);
}
delete this.onEnterFrame;
}
//} else {
//_root.picwidth = 'onbekend';
//}
}
}
function firstImage() {
picture._alpha = 0;
picture.loadMovie(image[0],1);
slideshow();
resizer();
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
picture._xscale = 100;
picture._yscale = 100;
}
}