Clutch
March 22, 2006, 10:59pm
1
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 ”]
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:
make sure the XML tag is different from the others (and closed).
change the name desc_det to something not so similar to the other one.
Clutch
March 24, 2006, 7:14am
3
changing desc_det to capt_txt worked, thx :krazy:
Clutch
March 24, 2006, 7:15am
4
changing desc_det to capt_txt worked, thx :krazy: