Hey!
Im trying to put a preloader for each slide so it looks good when people are visiting my site. I dont get any errors by using this code, but it doesn’t work at all. What I want to is like I said, put a preloader when the user click NEXT SLIDE and the preloader should xscale a rectangle so it has the width like the picture will (in this case 934 px). I have drawn a rectangle that is 1 px wide now and I linkaged that one as ‘stapel’. Like this site, that kind of preloader is what I want: http://www.fredrikstutterheim.com/oldFlash.php
This is what my code looks like now:
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("pictures.xml");
slides_xml.ignoreWhite = true;
clickSound = new Sound(this);
clickSound.attachSound("klick");
//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
}
}
//
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
}
//
// Event handler for 'Next slide' button
next_btn.onRelease = function() {
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
break;
} else {
//NYA
var totalSize; // den totala filmstorleken
var amountLoaded; // hur mycket som laddats ner
var percentComplete; // procent av den totala filmstorleken
totalSize=_root.getBytesTotal();
amountLoaded=_root.getBytesLoaded();
percentComplete=(amountLoaded/totalSize)*100;
_root.stapel._xscale=percentComplete;
if (percentComplete==100) {
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
//SLUT NYA
/* ORGINAL!
clickSound.start(0, 1);
clickSound.stop(klick);
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
*/
}
};
//
// Event handler for 'Previous slide' button
back_btn.onRelease = function() {
previousSlideNode = currentSlideNode.previousSibling;
if (previousSlideNode == null) {
break;
} else {
clickSound.start(0, 1);
clickSound.stop(klick);
currentIndex--;
currentSlideNode = previousSlideNode;
updateSlide(previousSlideNode);
}
};