# Kirupa's XML Gallery (Additional Dynamic Text)

**URL:** <https://forum.kirupa.com/t/kirupas-xml-gallery-additional-dynamic-text/182981>\
**Category:** flash\
**Created:** [March 22, 2006, 10:59pm UTC](https://forum.kirupa.com/t/kirupas-xml-gallery-additional-dynamic-text/182981 "2006-03-22T22:59:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clutch](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@Clutch](https://forum.kirupa.com/u/Clutch)\
**Post date:** [March 22, 2006, 10:59pm UTC](https://forum.kirupa.com/t/kirupas-xml-gallery-additional-dynamic-text/182981/1 "2006-03-22T22:59:07Z")

</div>

Hi all, hope you can help me out…

I stumbled on Kirupa’s tutorial on his XML guide and I think it is excellent! I plan to use multiple versions of it to setup a tier-level gallery, but I am coming into an issue…

I have tried to add a new description text field to call data from a new child node I’ve created called description. Everything else loads when adding the new code, but the text field remains “undefined”:

[COLOR=#003366]function loadXML(loaded) {[/COLOR]  
[COLOR=#003366]if (loaded) {[/COLOR]  
[COLOR=#003366]xmlNode = this.firstChild;  
image = [];  
description = [];  
caption = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++ ) {[/COLOR]  
[COLOR=#003366]image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
caption\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;[/COLOR]  
[COLOR=#003366]}  
firstImage();[/COLOR]  
[COLOR=#003366]} else {[/COLOR]  
[COLOR=#003366]content = “file not loaded!”;[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);  
/////////////////////////////////////  
listen = new Object();  
listen.onKeyDown = function() {[/COLOR]  
[COLOR=#003366]if (Key.getCode() == Key.LEFT) {[/COLOR]  
[COLOR=#003366]prevImage();[/COLOR]  
[COLOR=#003366]} else if (Key.getCode() == Key.RIGHT) {[/COLOR]  
[COLOR=#003366]nextImage();[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]};  
Key.addListener(listen);  
previous\_btn.onRelease = function() {[/COLOR]  
[COLOR=#003366]prevImage();[/COLOR]  
[COLOR=#003366]};  
next\_btn.onRelease = function() {[/COLOR]  
[COLOR=#003366]nextImage();[/COLOR]  
[COLOR=#003366]};  
/////////////////////////////////////  
p = 0;  
this.onEnterFrame = function() {[/COLOR]  
[COLOR=#003366]filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {[/COLOR]  
[COLOR=#003366]preloader.preload\_bar.\_xscale = 100\*loaded/filesize;[/COLOR]  
[COLOR=#003366]} else {[/COLOR]  
[COLOR=#003366]preloader.\_visible = false;  
if (picture.\_alpha\<100) {[/COLOR]  
[COLOR=#003366]picture.\_alpha += 10;[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]};  
function nextImage() {[/COLOR]  
[COLOR=#003366]if (p\<(total-1)) {[/COLOR]  
[COLOR=#003366]p++;  
if (loaded == filesize) {[/COLOR]  
[COLOR=#003366]picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
desc\_det.text = caption[p];  
picture\_num();[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]}  
function prevImage() {[/COLOR]  
[COLOR=#003366]if (p\>0) {[/COLOR]  
[COLOR=#003366]p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
desc\_det.text = caption[p];  
picture\_num();[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]}  
function firstImage() {[/COLOR]  
[COLOR=#003366]if (loaded == filesize) {[/COLOR]  
[COLOR=#003366]picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = description[0];  
desc\_det.text = caption[0];  
picture\_num();[/COLOR]  
[COLOR=#003366]}[/COLOR]  
[COLOR=#003366]}  
function picture\_num() {[/COLOR]  
[COLOR=#003366]current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;[/COLOR]  
[COLOR=#003366]}[/COLOR][URL=“[http://www.kirupa.com/forum/newthread.php?do=newthread&f=9](http://www.kirupa.com/forum/newthread.php?do=newthread&f=9)”]

---

<div class="post-metadata">

**Author:** ![goingNuts](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@goingNuts](https://forum.kirupa.com/u/goingNuts)\
**Post date:** [March 23, 2006, 1:10am UTC](https://forum.kirupa.com/t/kirupas-xml-gallery-additional-dynamic-text/182981/2 "2006-03-23T01:10:28Z")

</div>

> [@Clutch](#):
>
> Hi all, hope you can help me out…
> 
> I stumbled on Kirupa’s tutorial on his XML guide and I think it is excellent! I plan to use multiple versions of it to setup a tier-level gallery, but I am coming into an issue…
> 
> I have tried to add a new description text field to call data from a new child node I’ve created called description. Everything else loads when adding the new code, but the text field remains “undefined”:
> 
> [COLOR=#003366]function loadXML(loaded) {[/COLOR]  
> [COLOR=#003366]if (loaded) {[/COLOR]  
> [COLOR=#003366]xmlNode = this.firstChild;  
> image = ;  
> description = ;  
> caption = ;  
> total = xmlNode.childNodes.length;  
> for (i=0; i\<total; i++ ) {[/COLOR]  
> [COLOR=#003366]image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
> description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
> caption\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;[/COLOR]  
> [COLOR=#003366]}  
> firstImage();[/COLOR]  
> [COLOR=#003366]} else {[/COLOR]  
> [COLOR=#003366]content = “file not loaded!”;[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]}  
> xmlData = new XML();  
> xmlData.ignoreWhite = true;  
> xmlData.onLoad = loadXML;  
> xmlData.load(“images.xml”);  
> /////////////////////////////////////  
> listen = new Object();  
> listen.onKeyDown = function() {[/COLOR]  
> [COLOR=#003366]if (Key.getCode() == Key.LEFT) {[/COLOR]  
> [COLOR=#003366]prevImage();[/COLOR]  
> [COLOR=#003366]} else if (Key.getCode() == Key.RIGHT) {[/COLOR]  
> [COLOR=#003366]nextImage();[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]};  
> Key.addListener(listen);  
> previous\_btn.onRelease = function() {[/COLOR]  
> [COLOR=#003366]prevImage();[/COLOR]  
> [COLOR=#003366]};  
> next\_btn.onRelease = function() {[/COLOR]  
> [COLOR=#003366]nextImage();[/COLOR]  
> [COLOR=#003366]};  
> /////////////////////////////////////  
> p = 0;  
> this.onEnterFrame = function() {[/COLOR]  
> [COLOR=#003366]filesize = picture.getBytesTotal();  
> loaded = picture.getBytesLoaded();  
> preloader.\_visible = true;  
> if (loaded != filesize) {[/COLOR]  
> [COLOR=#003366]preloader.preload\_bar.\_xscale = 100\*loaded/filesize;[/COLOR]  
> [COLOR=#003366]} else {[/COLOR]  
> [COLOR=#003366]preloader.\_visible = false;  
> if (picture.\_alpha\<100) {[/COLOR]  
> [COLOR=#003366]picture.\_alpha += 10;[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]};  
> function nextImage() {[/COLOR]  
> [COLOR=#003366]if (p\<(total-1)) {[/COLOR]  
> [COLOR=#003366]p++;  
> if (loaded == filesize) {[/COLOR]  
> [COLOR=#003366]picture.\_alpha = 0;  
> picture.loadMovie(image[p], 1);  
> desc\_txt.text = description[p];  
> desc\_det.text = caption[p];  
> picture\_num();[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]}  
> function prevImage() {[/COLOR]  
> [COLOR=#003366]if (p\>0) {[/COLOR]  
> [COLOR=#003366]p–;  
> picture.\_alpha = 0;  
> picture.loadMovie(image[p], 1);  
> desc\_txt.text = description[p];  
> desc\_det.text = caption[p];  
> picture\_num();[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]}  
> function firstImage() {[/COLOR]  
> [COLOR=#003366]if (loaded == filesize) {[/COLOR]  
> [COLOR=#003366]picture.\_alpha = 0;  
> picture.loadMovie(image[0], 1);  
> desc\_txt.text = description[0];  
> desc\_det.text = caption[0];  
> picture\_num();[/COLOR]  
> [COLOR=#003366]}[/COLOR]  
> [COLOR=#003366]}  
> function picture\_num() {[/COLOR]  
> [COLOR=#003366]current\_pos = p+1;  
> pos\_txt.text = current\_pos+" / "+total;[/COLOR]  
> [COLOR=#003366]}[/COLOR]

everything looks to be in order. if you want to troubleshoot though, you might try:

1. make sure the XML tag is different from the others (and closed).
2. change the name desc\_det to something not so similar to the other one.

---

<div class="post-metadata">

**Author:** ![Clutch](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@Clutch](https://forum.kirupa.com/u/Clutch)\
**Post date:** [March 24, 2006, 7:14am UTC](https://forum.kirupa.com/t/kirupas-xml-gallery-additional-dynamic-text/182981/3 "2006-03-24T07:14:31Z")

</div>

> [@goingNuts](#):
>
> everything looks to be in order. if you want to troubleshoot though, you might try:
> 
> 1. make sure the XML tag is different from the others (and closed).
> 2. change the name desc\_det to something not so similar to the other one.

changing desc\_det to capt\_txt worked, thx :krazy:

---

<div class="post-metadata">

**Author:** ![Clutch](https://avatars.discourse-cdn.com/v4/letter/c/ce7236/32.png) [@Clutch](https://forum.kirupa.com/u/Clutch)\
**Post date:** [March 24, 2006, 7:15am UTC](https://forum.kirupa.com/t/kirupas-xml-gallery-additional-dynamic-text/182981/4 "2006-03-24T07:15:10Z")

</div>

> [@goingNuts](#):
>
> everything looks to be in order. if you want to troubleshoot though, you might try:
> 
> 1. make sure the XML tag is different from the others (and closed).
> 2. change the name desc\_det to something not so similar to the other one.

changing desc\_det to capt\_txt worked, thx :krazy:
