FMX: Reaching End of List in Random XML

Hello all,

most of you here seem familiar with the XML Photogallery. I’ve adapted it to something I am doing and it’s working swimingly. I’ve made it randomly cycle through.

It’s working great and I have Jhead nicely generating XML. All is good.

Except for one small problem. When I reach the last image in my XML file the cycling just stops. Not sure what is wrong but guess it has something to do with how I’m using ‘total’. I won’t include the entire AS, just the function that is not quite working right.

Also, I messed around for several hours, but if anyone has any pointers on having the loaded image fade out before the next one fades in I’d appreciate it.

[AS]
function autoImage()
{
if (p<(total-1)) {
p=random(total);
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
setInterval(autoImage, 8000);

[/AS]