Adapting the gallery tute for multiple dynamic galleries from only one XML file

Hi there, how’s it going? I was wondering if someone might give us a hand - I’m trying to adapt the XML photogallery tutorial (don’t we all?) for Flash MX so that I might load several galleries, or sets of pictures, from just one XML file.

My movie features 2 sets of previous/next buttons, one for the galleries and one for the photos within. Currently my XML contains 2 gallery nodes, which the gallery counter recognises, but when I click next gallery it fails to switch to the second gallery node’s children, simply reloading the first set again…

Here’s the offending code…

ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**function**[/COLOR] loadXML [COLOR=#000000]([/COLOR][COLOR=#0000FF]loaded[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]loaded[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    gallery = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
    image = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
    title = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
    info = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
    galleries = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]firstChild[/COLOR];
    gtotal = galleries.[COLOR=#0000FF]childNodes[/COLOR].[COLOR=#0000FF]length[/COLOR];
    [COLOR=#0000FF]for[/COLOR][COLOR=#000000]([/COLOR]g=[COLOR=#000080]0[/COLOR]; g<gtotal; g++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        pic = galleries[COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
        gallery[COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
        images = galleries.[COLOR=#0000FF]firstChild[/COLOR];
        total = images.[COLOR=#0000FF]childNodes[/COLOR].[COLOR=#0000FF]length[/COLOR];
        [COLOR=#0000FF]for[/COLOR][COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i<total; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
            image[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = images.[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000FF]firstChild[/COLOR].[COLOR=#0000FF]nodeValue[/COLOR];
            title[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = images.[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000FF]firstChild[/COLOR].[COLOR=#0000FF]nodeValue[/COLOR];
            info[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = images.[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000FF]firstChild[/COLOR].[COLOR=#0000FF]nodeValue[/COLOR];
        [COLOR=#000000]}[/COLOR]
    [COLOR=#000000]}[/COLOR]
    firstGallery[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];

[/LEFT]
[/FONT]

And this here is the code for the prev/next gallery functions…

ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**function**[/COLOR] nextGallery[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]c<[COLOR=#000000]([/COLOR]gtotal-[COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    c++;
    gallery = galleries [COLOR=#000000][[/COLOR]c[COLOR=#000000]][/COLOR];
    gallery_num[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    firstImage[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]
[COLOR=#000000]function[/COLOR] prevGalleryCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
c–;
gallery_numCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]

I’ve been playing around with it for days with no luck, and I’m pretty sure the solution is straight forwards… Any thoughts?

Cheers, and keep up the good work!

-d