# Preloader for XML loaded picture slider

**URL:** https://forum.kirupa.com/t/preloader-for-xml-loaded-picture-slider/172852
**Category:** flash
**Created:** [December 18, 2005, 10:04pm UTC](https://forum.kirupa.com/t/preloader-for-xml-loaded-picture-slider/172852 "2005-12-18T22:04:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rome](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rome](https://forum.kirupa.com/u/rome)
#### Post date: [December 18, 2005, 10:04pm UTC](https://forum.kirupa.com/t/preloader-for-xml-loaded-picture-slider/172852/1 "2005-12-18T22:04:10Z")

</div>

The script below creates a slideshow of images. I’ve been trying to create (1) a preloader that will load all the images before showing any of them or (2) a preloader for each individual image.  
Can anyone help?

```auto
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("food.xml");
////////////// arranges contents of XML data into two arrays
///// image - which is a url to the image
///// widths - the width of the image (necessary for setlocation() function)
function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		widths = [];
		totalwidths = [];
		totalwidths[0] = 0;
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			widths* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
		}
		for (i=0, count=0, j=1; i<total; i++, j++) {
			y = widths* - 0;
			count = count+ y + 3;
			totalwidths[j] = count;
		}
		loadimages();
	}
};
/////////// loads the images into individual movieclips
function loadimages() {
	widths = [];
	var totalwidth = 0;
	for (i=0;i<total; i++) {
		var picref = this.createEmptyMovieClip("container"+i,i);
		picref.loadMovie(image*);
	}
	setLocation();
};
//////////////// sets the _x location of the images
function setLocation() {
	for (i=0; i<total; i++) {
		var contain = "container"+i;
		setProperty (contain,_x,totalwidths*);		
	}
};
////////////////// scoller limits
this.onEnterFrame = function() {
	var rightposition = (700 - 344 - totalwidths[total]);
	if (_root.nav.contents._x >= -344) {
		tellTarget ("_level0.nav.scroller.scroll_right") {
			gotoAndStop(1);
			enabled = false;
		}
	} else {
		tellTarget ("_level0.nav.scroller.scroll_right") {
			enabled = true;
		}
	}
	if (_root.nav.contents._x <= rightposition) {
		tellTarget ("_level0.nav.scroller.scroll_left") {
			gotoAndStop(1);
			enabled = false;
		}
	} else {
		tellTarget ("_level0.nav.scroller.scroll_left") {
			enabled = true;
		}
	}
};

```
