# Preloader for each slide

**URL:** https://forum.kirupa.com/t/preloader-for-each-slide/167584
**Category:** Uncategorized
**Created:** [October 29, 2005, 5:22pm UTC](https://forum.kirupa.com/t/preloader-for-each-slide/167584 "2005-10-29T17:22:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![clieee](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@clieee](https://forum.kirupa.com/u/clieee)
#### Post date: [October 29, 2005, 5:22pm UTC](https://forum.kirupa.com/t/preloader-for-each-slide/167584/1 "2005-10-29T17:22:51Z")

</div>

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](http://www.fredrikstutterheim.com/oldFlash.php)

This is what my code looks like now:

```php

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);
	}
};

```
