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

**URL:** <https://forum.kirupa.com/t/adapting-the-gallery-tute-for-multiple-dynamic-galleries-from-only-one-xml-file/183900>\
**Category:** flash\
**Created:** [March 31, 2006, 1:15am UTC](https://forum.kirupa.com/t/adapting-the-gallery-tute-for-multiple-dynamic-galleries-from-only-one-xml-file/183900 "2006-03-31T01:15:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![doktor\_chonze](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@doktor\_chonze](https://forum.kirupa.com/u/doktor_chonze)\
**Post date:** [March 31, 2006, 1:15am UTC](https://forum.kirupa.com/t/adapting-the-gallery-tute-for-multiple-dynamic-galleries-from-only-one-xml-file/183900/1 "2006-03-31T01:15:38Z")

</div>

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&lt;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&lt;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&lt;[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
