# XML Kicking my Butt

**URL:** <https://forum.kirupa.com/t/xml-kicking-my-butt/214660>\
**Category:** flash\
**Created:** [January 30, 2007, 10:22pm UTC](https://forum.kirupa.com/t/xml-kicking-my-butt/214660 "2007-01-30T22:22:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kick\_me](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kick\_me](https://forum.kirupa.com/u/kick_me)\
**Post date:** [January 30, 2007, 10:22pm UTC](https://forum.kirupa.com/t/xml-kicking-my-butt/214660/1 "2007-01-30T22:22:49Z")

</div>

I have no idea what i am doing.  
I have the XML & Actionscriting set up too pull in all of the info in, But i cant not for the life of me get the URL’s to work.

And if there are Hints on how to clean this up, That would be great

var xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“news.xml”);

/////////////////////////////////////  
xmlData.onLoad = function(loaded){  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
headline = [];  
caption = [];  
nav = [];  
fullstory = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
headline\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
caption\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
nav\* = xmlNode.childNodes\*.childNodes[3].firstChild.nodeValue;  
fullstory\* = xmlNode.childNodes\*.childNodes[4].firstChild.nodeValue;  
strURL\* = xmlNode.firstChild.childNodes[4].attributes.url;  
}  
firstImage();  
navtext();  
} else {  
content = “file not loaded!”;  
}  
}

/////////////////////////////////////  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
}  
if (Key.getCode) {  
btnOne();  
btnTwo();  
btnthree();  
btnfour();  
}

```
else if (Key.getCode() == Key.RIGHT) {
    firstImage();
}

```

};

Key.addListener(listen);  
previous\_btn.onRelease = function() {  
prevImage();  
};  
next\_btn.onRelease = function() {  
nextImage()  
};  
btn\_one.onRelease = function() {  
btnOne();  
clearInterval(myInterval);  
};  
btn\_two.onRelease = function() {  
btnTwo();  
clearInterval(myInterval);  
};  
btn\_Three.onRelease = function() {  
btnthree();  
clearInterval(myInterval);  
};  
btn\_Four.onRelease = function() {  
btnfour();  
clearInterval(myInterval);  
};

/////////////////////////////////////  
p = 0;  
this.onEnterFrame = function() {  
filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {  
preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
if (picture.\_alpha\<100) {  
picture.\_alpha += 5;  
}  
if (desc\_txt.\_alpha\<100) {  
desc\_txt.\_alpha += 10;  
}  
}  
};

function btnOne() {  
p=0;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = headline[p];  
caption\_txt.text = caption[p];  
one.fullstory\_txt.text = fullstory[0];

}

function btnTwo() {  
p=1;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = headline[p];  
caption\_txt.text = caption[p];  
one.fullstory\_txt.text = fullstory[1];  
}

function btnthree() {  
p=2;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = headline[p];  
caption\_txt.text = caption[p];  
one.fullstory\_txt.text = fullstory[2];  
}

function btnfour() {  
p=3;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = headline[p];  
caption\_txt.text = caption[p];  
one.fullstory\_txt.text = fullstory[3];  
}

function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = headline[p];  
caption\_txt.text = caption[p];  
slideshow();  
}  
}

function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = headline[p];  
caption\_txt.text = caption[p];  
one.fullstory\_txt.text = fullstory[p];  
slideshow();  
}  
}  
}

function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = headline[0];  
caption\_txt.text = caption[p];  
one.fullstory\_txt.text = fullstory[0];  
slideshow();  
}  
}

delay = 3000;

function slideshow() {  
myInterval = setInterval(pause\_slideshow, delay);  
function pause\_slideshow() {  
clearInterval(myInterval);  
if (p == (total-1)) {  
p = 0;  
firstImage()  
} else {  
nextImage();  
}  
}  
}

function navtext() {  
nav1\_txt.text = nav[0];  
nav2\_txt.text = nav[1];  
nav3\_txt.text = nav[2];  
nav4\_txt.text = nav[3];  
}

///////////////////////////////////////////////////////////////////////////////////////////////

\<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?\>  
\<images\>  
\<pic\>  
\<image\>news\_images/hura.jpg\</image\>  
\<headline\>text\</headline\>  
\<caption\>text\</caption\>  
\<nav\>text\</nav\>  
\<fullstory url=“[http://www.google.com/](http://www.google.com/)”\>1\</fullstory\>  
\</pic\>  
\<pic\>  
\<image\>news\_images/meso.jpg\</image\>  
\<headline\>text\</headline\>  
\<caption\>text\</caption\>  
\<nav\>text\</nav\>  
\<fullstory url=“[http://www.yahoo.com/](http://www.yahoo.com/)”\>2\</fullstory\>  
\</pic\>  
\<pic\>  
\<image\>news\_images/ortho.jpg\</image\>  
\<headline\>text\</headline\>  
\<caption\>text\</caption\>  
\<nav\>text\</nav\>  
\<fullstory url=“[http://www.msn.com/](http://www.msn.com/)”\>3\</fullstory\>  
\</pic\>  
\<pic\>  
\<image\>news\_images/stent.jpg\</image\>  
\<headline\>text\</headline\>  
\<caption\>text\</caption\>  
\<nav\>text\</nav\>  
\<fullstory url=“[http://www.photo.com/](http://www.photo.com/)”\>4\</fullstory\>  
\</pic\>  
\</images\>
