Hi,
I used the script from the XML photo gallery tutorial and added buttons so you can see which image is showed. Bassicaly it’s a movie clip that switches to another frame in the button mv when current image is active. It’s working fine, but i got one problem, when the gallery loops back to the first image, that button isn’t changing to on, all the others continue fine.
Here’s the code I got so far for the buttons:
function buttonList() {
current_pos = p+1;
for(var i:Number = 0; i < total; i++) {
holder.attachMovie("button", "mcButton"+i, holder.getNextHighestDepth());
holder["mcButton"+i]._x= (holder["mcButton"+i]._width+spacer)*i;
if (current_pos == i+1) {
holder["mcButton"+i].gotoAndStop(5);
} else {
holder["mcButton"+i].gotoAndStop(1);
}
}
}
and here’s the full code
delay = 1000;
var spacer:Number = 2;
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
titel = [];
tekst = [];
image = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
titel* = xmlNode.childNodes*.childNodes
[0].firstChild.nodeValue;
tekst* = xmlNode.childNodes*.childNodes
[1].firstChild.nodeValue;
image* = xmlNode.childNodes*.childNodes
[2].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("assets/hotitems.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 += 5;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
txt_title.text = titel[p];
txt_text.text = tekst[p];
picture_num();
slideshow();
buttonList();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
txt_title.text = titel[p];
txt_text.text = tekst[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
txt_title.text = titel[0];
txt_text.text = tekst[0];
picture_num();
slideshow();
buttonList();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
[COLOR=red]function buttonList() {[/COLOR]
[COLOR=red]current_pos = p+1;[/COLOR]
[COLOR=red]for(var i:Number = 0; i < total; i++) {[/COLOR]
[COLOR=red]holder.attachMovie("button", "mcButton"+i, holder.getNextHighestDepth());[/COLOR]
[COLOR=red]holder["mcButton"+i]._x= (holder["mcButton"+i]._width+spacer)*i;[/COLOR]
[COLOR=red]if (current_pos == i+1) {[/COLOR]
[COLOR=red] holder["mcButton"+i].gotoAndStop(5);[/COLOR]
[COLOR=red]} else {[/COLOR]
[COLOR=red] holder["mcButton"+i].gotoAndStop(1);[/COLOR]
[COLOR=red]}[/COLOR]
[COLOR=red]}[/COLOR]
[COLOR=red]}[/COLOR]
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}
and a acreenshot