Problems with xml & attachmovie for the first time!

Hi,
this is the first time i encountered something of this kind.
Have a look at the below code. All it does is load an xml and depending on the nodes, it will create titles and galleries below titles so it would look like that:

title1
gallery1
gallery2
title2
gallery3
gallery4
gallery5


galleriesData.ignoreWhite = true;
galleriesData.onLoad = function(success) {
    xmlNode = this.firstChild;
    total = xmlNode.childNodes.length;
    cspacing = 40;
    gspacing = 100;
    for (i=0; i<total; i++) {
        newTitle = _root.attachMovie("menuTitle", "title"+i, _root.getNextHighestDepth());
        newTitle._y = hght + i*cspacing;
        newTitle._x = 0;
        newTitle.title.text = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
        len = xmlNode.childNodes*.childNodes[1].childNodes.length;
        hght = _root._height;
        if (len > 0) {
            for (j=0; j<len; j++) {
                newGallery = _root.attachMovie("submenuEntry", "submenuEntry"+j, _root.getNextHighestDepth());
                newGallery._x = 30;
                if (j == 0) newGallery._y = hght + 50;
                else newGallery._y = hght + j*gspacing;
                newGallery.title.text = xmlNode.childNodes*.childNodes[1].childNodes[j].childNodes[0].firstChild.nodeValue;
                newGallery.desc.text = xmlNode.childNodes*.childNodes[1].childNodes[j].childNodes[1].firstChild.nodeValue;
                picLoader = newGallery.createEmptyMovieClip(j, 0);
                picLoader.loadMovie(xmlNode.childNodes*.childNodes[1].childNodes[j].childNodes[2].firstChild.nodeValue);
                }
            }
        hght = _root._height;
    }
}


galleriesData.load("data/menu.xml");

The problem is that although the code does attach movies correctly through the library, it will not load all thumbnails, but only the last in each for loop.
Titles will show up ok (the first for loop). The second for loop (the nested one) is the one that gives me headaches. It always will only load the last gallerie’s thumbnail. So if you were to have 2 titles, one with 2 galleries and one with 3, this code would only load the second thumb for the first title and the third for the second title.

I suppose it has to do with the for and the instances and whatnot but up till now i didnt have any problems with this code snippet. I also tried using a movieClipLoader but it has the same effect.

What is it i am doing wrong?
I might be overlooking something big do to so many hours of looking at it.

picLoader = newGallery.createEmptyMovieClip(j, 0);

I think it may be this line, each clip is created at the same depth -try change the 0 to j.

yes i think i tried that as well.
I will try again, however keep in mind that this movie clip is created only once in each “parent” movie clip so that shouldnt be a problem at all :frowning:

(and as i said, i just tried it and its not this part of the code).
I even copied and pasted the whole code block on a new file and it still does the same thing…

just solved it.
it was a problem of the instance name i was giving to the second loop entries…
the way it was i was overwritting them over :slight_smile: