Photos loaded from XML


i found great tutorial on how create photo gallery loads content xml file. right now, code cycles through pictures, , when reaches end stops. also, when first launch gallery (at beginning/first picture), previous button nothing. alter create loop, there no end. when reach end of array, "next" button starts @ beginning, , when you're @ first picture in gallery, "previous" button goes last picture. here's 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();
}
};
key.addlistener(listen);
previous_btn.onrelease = function() {
previmage();
};
next_btn.onrelease = function() {
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];
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;
}

any help, ideas, suggestions, comments, or simple hello's appreciated. in advance! laters..........

it great have @ fla file see how have set up. there many possibilities it.


More discussions in ActionScript 1 and 2


adobe

Comments