XML ImageSlider

Hi Folks,

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


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

yours
Matze K.

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


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.