I have just complete the Photo Gallery tutorial and am trying to modify it as a next step. I have added another child called “header” in the XML file as such:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>images/clean.jpg</image>
<caption>Some text.</caption>
<header>Tomorrow's clean room today.</header>
</pic>
<pic>
<image>images/color.jpg</image>
<caption>More text.</caption>
<header>Pick A Color</header>
</pic>
<pic>
<image>images/video.jpg</image>
<caption>Even More text.</caption>
<header>See It Now!</header>
</pic>
</images>
I created another dynamic text field and named the instance “header_txt”.
I am trying to create an array of the children here in the actionscript:
xmlNode = this.firstChild;
image = [];
description = [];
header = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
header* = xmlNode.childnodes*.childNodes[2].firstChild.nodeValue;
}
I don’t think that last line is correct for getting the headers, how should it be written? I keep getting “undefined” when I test.
Just for more info, here is script that is called when you hit button 1. (I am having 3 buttons, one for each image like a navigation):
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
header_txt.text = header[0];
picture_num();
}
The images and the captions all load fine, but not the header, can anyone tell what I am doing wrong? Thanks