codice:
images_xml = new XML();
images_xml.onLoad = startImageViewer;
images_xml.load("xml/images.xml");
images_xml.ignoreWhite = true;
function startImageViewer(success) {
if (success == true) {
rootNode = images_xml.firstChild;
totalImages = rootNode.childNodes.length;
firstImageNode = rootNode.firstChild;
currentImageNode = firstImageNode;
currentIndex = 1;
updateImage(firstImageNode);
}
}
function updateImage(newImageNode, wdt, hgt) {
imagePath = newImageNode.attributes.imgURL;
targetClip._alpha = 0;
a = setInterval(preload, 200, wdt, hgt);
targetClip.loadMovie(imagePath);
imageCount = "image " + currentIndex + " of " + totalImages;
}
next_btn.onRelease = function()
{
nextImageNode = currentImageNode.nextSibling;
if (nextImageNode == null) {
break;
} else {
currentIndex++;
updateImage(nextImageNode, 120, 100);
currentImageNode = nextImageNode;
}
};
function preload(wdt, hgt) {
car = targetClip.getBytesLoaded();
tot = targetClip.getBytesTotal();
perc = Math.round((car / tot) * 100);
imagestat.text = "Loading... " + perc + "%";
if (car == tot && targetClip._url != _root.url) {
targetClip._width = wdt;
targetClip._height = hgt;
clearInterval(a);
imagestat.text = "";
targetClip._alpha=100;
}
}