hey, im using xml for the fist time with AS2.
I am not a coder … just a designer (so please excuse my dumb actionscript)
I used kirupa’s XML photogallery tutorial and edited it down for what i need. Except right now it only shows a series of images within one set.
… but I want to be able to structure my XML like: (with multiple images under each set obviously-- im just showing one here)
<set1>
<pic>
<image>set1/1.jpg</image>
</pic>
</set1>
<set2>
<pic>
<image>set2/1.jpg
</pic>
</set2>
I’ve got some buttons on the side, labeled (set1), (set2) etc… and when you click set2, I would like it to jump to in the xml and load those images.
right now, I am doing it VERY wrong (see AS below) — I am loading in a seperate .xml for each set, which would end up being ALOT of .xml files
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!";
}
}
set1.onRelease = function() {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
};
set2.onRelease = function() {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images2.xml");
};
set3.onRelease = function() {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images3.xml");
};
one.onRelease = function() {
oneImage();
};
two.onRelease = function() {
twoImage();
};
three.onRelease = function() {
threeImage();
};
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 oneImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0],1);
desc_txt.text = description[0];
}
}
function twoImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[1],1);
desc_txt.text = description[1];
}
}
function threeImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[2],1);
desc_txt.text = description[2];
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0],1);
desc_txt.text = description[0];
picture_num();
}
}
your help is much appreciated
thanks