# XML ImageSlider

**URL:** https://forum.kirupa.com/t/xml-imageslider/14868
**Category:** flash
**Created:** [March 3, 2003, 8:33pm UTC](https://forum.kirupa.com/t/xml-imageslider/14868 "2003-03-03T20:33:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Madokan](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@Madokan](https://forum.kirupa.com/u/Madokan)
#### Post date: [March 3, 2003, 8:33pm UTC](https://forum.kirupa.com/t/xml-imageslider/14868/1 "2003-03-03T20:33:52Z")

</div>

Hi Folks,

Just a little XML fun - maybe you will find it useful for something - real different. 😉

```php

myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("bilderx.xml");
loadstatus.text = "LOADING...";
myXML.onLoad = function(status) {
	if (status) {
		tempxml = myXML.firstChild.childNodes;
		maxEntries = tempxml.length;
		_root.slideBand("container", "image", 1, 0, 10.0, maxEntries, 200, 1, 1.1, 120);
		loadstatus.text = "";
		delete myXML;
	}
};

function slideBand(obj, clip, depth, target, speed, maxImages, imgWidth, imgNr, distance, posY) {
	createEmptyMovieClip(obj, depth);
	for (var i = 1; i <= maxImages; i++) {
		this[obj].attachMovie(clip, clip + i, i);
		this[obj][clip + i]._x = this[obj][clip add i]._width * i * distance;
		this[obj][clip + i]._y = posY;
		this[obj][clip + i].image = i;
		this[obj][clip + i].titel.text = tempxml[i-1].attributes.titel;
		this[obj][clip + i].onRelease = function() {
			imgNr = this.image;			
		};
		this[obj][clip + i].mc.loadMovie("picsxml/" + tempxml[i-1].firstChild);
		this[obj][clip + i].balken_mc._xscale = 0
		this[obj][clip + i].onEnterFrame = function() {
			if (this.mc.getBytesLoaded() > 10) {
			this.totalB = this.mc.getBytesTotal();			
			this.loadedB = this.mc.getBytesLoaded();		
			this.prozent = this.loadedB*100/this.totalB;
			this.balken_mc._xscale = this.prozent;
			if (this.prozent == 100) { 
				this.balken_mc._visible = 0;
				delete this.onEnterFrame;
			}
			}
		};
	}
	this[obj].onEnterFrame = function() {		
		this.xdiff = this[clip + imgNr]._x - target;		
		if (this.xdiff != 0) {			
			this.xdiff = this.xdiff / speed;			
			for (var i = 1; i <= maxImages; i++) {
				this[clip + i]._x -= this.xdiff;
				if (this[clip + i]._x <= (target - imgWidth)) {
					this[clip + i]._x += maxImages * imgWidth * distance;
				}
			}
		}
	};
}

```

Example:  
[have look](http://www.flashangel.de/xmldias/)

yours  
Matze K.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 4, 2003, 6:05pm UTC](https://forum.kirupa.com/t/xml-imageslider/14868/2 "2003-03-04T18:05:33Z")

</div>

Flash and it’s rounding-errors! Here the optimized version. 🙂

```php

myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("bilderx.xml");
loadstatus.text = "LOADING...";
myXML.onLoad = function(status) {
	if (status) {
		tempxml = myXML.firstChild.childNodes;
		maxEntries = tempxml.length;
		_root.slideBand("container", "image", 1, 0, 10.0, maxEntries, 200, 1, 1.1, 120);
		loadstatus.text = "";
		delete myXML;
	}
};

function slideBand(obj, clip, depth, target, speed, maxImages, imgWidth, imgNr, distance, posY) {
	createEmptyMovieClip(obj, depth);
	for (var i = 1; i <= maxImages; i++) {
		this[obj].attachMovie(clip, clip + i, i);
		this[obj][clip + i]._x = imgWidth * i * distance;
		this[obj][clip + i]._y = posY;
		this[obj][clip + i].image = i;
		this[obj][clip + i].titel.text = tempxml[i-1].attributes.titel;
		this[obj][clip + i].onRelease = function() {
			imgNr = this.image;			
		};
		this[obj][clip + i].mc.loadMovie("picsxml/" + tempxml[i-1].firstChild);
		this[obj][clip + i].balken_mc._xscale = 0
		this[obj][clip + i].onEnterFrame = function() {
			if (this.mc.getBytesLoaded() > 10) {
			this.totalB = this.mc.getBytesTotal();			
			this.loadedB = this.mc.getBytesLoaded();		
			this.prozent = this.loadedB*100/this.totalB;
			this.balken_mc._xscale = this.prozent;
			if (this.prozent == 100) { 
				this.balken_mc._visible = 0;
				delete this.onEnterFrame;
			}
			}
		};
	}
	this[obj].onEnterFrame = function() {		
		this.xdiff = this[clip + imgNr]._x - target;		
		if (this.xdiff != 0) {			
			this.xdiff = Math.round(this.xdiff) / Math.round(speed);			
			for (var i = 1; i <= maxImages; i++) {
				this[clip + i]._x -= this.xdiff;
				if (this[clip + i]._x <= (target - imgWidth)) {
					this[clip + i]._x += maxImages * imgWidth * distance;
				}
			}
		}
	};
}

```

yours  
Matze K.
