Multiple instances of XML photo gallery

I am creating a complex photo gallery application with XML. Through the XML you may load individual images, or you may create mini photo galleries within the main application.

At first, individual images and mini galleries are treated the same, I loop through data from the XML to create each instance.

The mini gallerie’s are then populated by a second loop within the first, to draw data from the next level of XML childNodes. For the mini gallery code I am using a modified version of http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm

What I have now works perfectly if there is only one mini gallery. As soon as I create a second mini gallery, the first one stops working. Or rather, the next and previous buttons from the first mini gallery control the second mini gallery rather than the first.

This seams strange to me because there are many other functions relating to the individual images that are created within the main “for” loop that work fine regardless of how many instances of individual images there are. The mini gallery functions are also located inside the main “for” loop, but rather than functioning for each mini gallery instance they work only for the last one created.

I hope this descriptions is clear. I’m no expert at AS. I’d paste my AS code but it’s way too long to post here!

**How do I need to modify the photo gallery script to allow for multiplt instances of it??

**Thanks for your help Kirupians!