g’day sirs,
i have the following code and i’m loading portrait and landscape images into an empty mc via xml but the images load to x = 0 and y = 0. is there any way to load these images “centered” into that mc ?
delay = 3000;
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();
} else {
content = "XML OOPS !";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("flyer.xml");
p = 0;
function preload(clip) {
picture.loadMovie(clip);
var temp = this.createEmptyMovieClip("temp", 9987);
temp.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
if (filesize>4 && filesize == loaded) {
picture._alpha += 1;
if (picture._alpha>100) {
picture._alpha = 100;
slideshow();
delete this.onEnterFrame;
}
}
};
}
function nextImage() {
if (p == (total-1)) {
p = -1;
}
if (p<(total-1)) {
p++;
fadeOut(image[p]);
}
}
function firstImage() {
picture._alpha = 0;
fadeOut(image[0]);
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
nextImage();
}
}
function fadeOut(clip) {
picture.onEnterFrame = function() {
this._alpha -= 1;
if (this._alpha<1) {
preload(clip);
delete this.onEnterFrame;
}
};
}
sorry if this sounds weird but i don’t know how to explain it more clearly
thank you for reading
Yep, i have the exact same problem and still haven’t found a fix. I am in the middle of one though.
Do a subholder.
Pseudo code follows;
var holder:MovieClip = this.createEmptyMovieClip("holder", 10);
var subholder:MovieClip = holder.createEmptyMovieClip("subholder",1);
loadClip(url, subholder);
onLoadInit = f() {
subholder._x = 0 - subholder._width/2;
subholder._y = 0 - subholder._height/2;
I’m sure you get the gist of it.
thank you for your answer - unfortunately it doesn’t seem to work - the images are still loaded into the “holder” mc and thus wouldn’t position centered
what do want these images centered to? the stage? the browser? anytime flash loads an image it’s position is x -0, y-0. one way to center these images is to create a movieclip to load the xml file and use actionscript to center the image to the movieclip and then center the image to the stage. an example can be post on request.
i know - but i thougth there would be a nice workaroud
but don’t mind - i’m over it 
yiou make ti load them with mociecliploader into a container then you subtract the width of the container / 2 . you can use loadmovie but I wouldhave to post the ‘workaround’ code to show youi how to get the width of a loadMovie image… and right noew thats a bit hard </3
if you just want to center to a point -just change to
var centerX=300
var centerY =300
function preload(clip) {
picture.loadMovie(clip);
var temp = this.createEmptyMovieClip("temp", 9987);
temp.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
if (filesize>4 && filesize == loaded) {
picture._x =centerX-picture._width/2
picture._y = centerY-picture._height/2
picture._alpha += 1;
if (picture._alpha>100) {
picture._alpha = 100;
slideshow();
delete this.onEnterFrame;
}
}
};
}
if you were wanting to scale the loaded clips from the center then an easy way is to create another clip inside picture and load into that.