# XML in Flash MX 2004 / Works partially. Help

**URL:** <https://forum.kirupa.com/t/xml-in-flash-mx-2004-works-partially-help/151849>\
**Category:** flash\
**Created:** [June 18, 2005, 6:42pm UTC](https://forum.kirupa.com/t/xml-in-flash-mx-2004-works-partially-help/151849 "2005-06-18T18:42:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelone](https://avatars.discourse-cdn.com/v4/letter/p/9fc348/32.png) [@pixelone](https://forum.kirupa.com/u/pixelone)\
**Post date:** [June 18, 2005, 6:42pm UTC](https://forum.kirupa.com/t/xml-in-flash-mx-2004-works-partially-help/151849/1 "2005-06-18T18:42:01Z")

</div>

First of all, I thought Flashkit was the bomb - I was wrong KIRUPA is the shiznit (BOMB DIGITY) the best forum. ok wooo had to get that out.

Following on Tutorial: [http://www.kirupa.com/developer/mx2004/xml\_flash\_photogallery.htm](http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm)

I love it i was able to figure it out, but I realized something. The counter and getting back and forth through the gallery. Say I have 200 pics and I hit next all the way to see the last pic; Instead of clicking prev all the way to number one. I was trying to add another button - that would take me all the way to 1/200.

//This code added by Pixelone to to jump right to 1/200.  
function frontImage() {  
if (loaded == filesize) {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie (image [0], 1);  
desc\_txt.text = description[0];  
picture\_num();

```
}

```

The buitton works and it takes to the first image in the set, but the counter remains unchanged. So I will be at the front and the counter will say 5/200 still for thats how far I had scroll to.

Not sure if it is making sense.

Here is the entire Code:

function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
description = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;

```
    }
    firstImage();
} else {
    content = "file not loaded!";
}

```

}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);  
/////////////////////////////////////  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
if (Key.getCode() == Key.LEFT) {  
frontImage();  
}

```
}

```

};  
Key.addListener(listen);  
back\_button.onRelease = function() {  
prevImage();  
};  
next\_button.onRelease = function() {  
nextImage();  
};  
// This function was added by Pixelone to enable front button  
Key.addListener(listen);  
front\_button.onRelease = function () {  
frontImage();  
};  
/////////////////////////////////////  
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 += 10;  
}  
}  
};  
//This code aded by Pixelone to activate front button.  
function frontImage() {  
if (loaded == filesize) {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie (image [0], 1);  
desc\_txt.text = description[0];  
picture\_num();

```
}

```

}  
}

function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
}  
}  
}  
function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = description[0];  
picture\_num();  
}  
}  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}
