I’ve followed along with image gallery/slideshow tutorial and it works great. However, I’m trying to make it a bit more complex in which I need to access nested loops. I’ve tried a few things, but nothing seems to work. Any help would be greatly appreciated.
Here is my XML:
<resorts looptime="2">
<location>
<image>images/pic01.jpg</image>
<island>Island 1</island>
<link>http://www.google.com</link>
<bullets>
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
<item>Item 4</item>
</bullets>
</location>
<location>
<image>images/pic02.jpg</image>
<island>Island 2</island>
<link>http://www.google.com</link>
<bullets>
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
<item>Item 4</item>
</bullets>
</location>
<location>
<image>images/pic03.jpg</image>
<island>Island 3</island>
<link>http://www.google.com</link>
<bullets>
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
<item>Item 4</item>
</bullets>
</location>
The nested loop is bullets. This is where I’m having my problem.
Here is my AS:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
island = [];
link = [];
bullets = [];
total = xmlNode.childNodes.length;
delay = (this.firstChild.attributes.looptime)*1000;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
island* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
link* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
bullets* = xmlNode.childNodes*.childNodes[3].firstChild;
}
// my effort a nested loop
for (b=0; b<bullets*.length; b++){
item = bullets*.firstChild.nodeValue;
trace(item);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("info.xml");
I’ve tried doing a simple loop but for the life of me, I can’t seem to get it to work. Thanx in advance!