Link to home
Start Free TrialLog in
Avatar of smoothmonster
smoothmonster

asked on

Actionscript 2 looping through xml nodes to pull according to button selection

I have eight INFO buttons that once you click pulls up a popup/Movie clip with a picture, title, and description being pulled from an xml file. My next button doesn't seem to work either.

I want to be able to tell which xml nodes to pull based on which INFO button is pressed.

sample work: http://www.smooth-ness.com/flash.html

Select "Terrace Options" Then at the bottom the "INFO" button. There will be an info button by all items listed.
function loadXML(loaded) {
 
if (loaded) {
 
xmlNode = this.firstChild;
image = [];
titlehere = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
 
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
titlehere[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[2].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();
 
}
 
};
Key.addListener(listen);
previous_btn.onRelease = function() {
 
prevImage();
 
};
next_btn.onRelease = function() {
trace(clicked);
nextImage();
 
};
/////////////////////////////////////
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;
 
}
 
}
 
};
function nextImage() {
 
if (p<(total-1)) {
 
p++;
if (loaded == filesize) {
 
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
title_txt.text = titlehere[p];
 
picture_num();
 
}
 
}
 
}
function prevImage() {
 
if (p>0) {
 
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
title_txt.text = titlehere[p];
 
picture_num();
 
}
 
}
function firstImage() {
 
if (loaded == filesize) {
 
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
title_txt.text = titlehere[1];
picture_num();
 
}
 
}
function picture_num() {
 
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smoothmonster
smoothmonster

ASKER

Thanks blue-genie, I needed a place to start and this gets me on the right path. Thank you.