var pic = new Array();
var current = 0;
var loaded = 0;
var IV = 0;
var centerX = 296;
// Mittelpunkt der Bühne!
var centerY = 57.5;
var timeout = 6000;
// Zeit zwischen den Bildern!
var xm = new XML();
xm.ignoreWhite = true;
xm.load("banner.txt");
xm.onLoad = function() {
parse(this);
};
function parse(obj) {
for (var i = 0; i<obj.childNodes.length; i++) {
pic[i] = this.createEmptyMovieClip("pic"+i, i+512);
pic[i].ct = pic[i].createEmptyMovieClip("ct", 1);
pic[i]._alpha = 0;
pic[i].nr = i;
pic[i]._x = centerX;
pic[i]._y = centerY;
pic[i].go = function() {
// Einblenden
this.onEnterFrame = function() {
this._alpha += (100-this._alpha)/6;
if (this._alpha>=98) {
this._alpha = 100;
this._parent.nextPic(this.nr);
// ruft Funktion zum Anzeigen des
// nächsten Bildes auf
delete this.onEnterFrame;
}
};
};
pic[i].hold = function() {
// Ausblenden
this.onEnterFrame = function() {
this._alpha += (0-this._alpha)/15;
if (this._alpha<=2) {
this._alpha = 0;
delete this.onEnterFrame;
}
};
};
pic[i].ct.loadMovie(obj.childNodes[i].attributes.picture);
pic[i].onEnterFrame = function() {
if (this.ct._width>10 && this.ct._height>10) {
this.ct._x = -this.ct._width/2;
this.ct._y = -this.ct._height/2;
this._parent.nextLoaded();
delete this.onEnterFrame;
}
};
}
}
function showPic(nr) {
// Blendet ein Bild ein
clearInterval(IV);
if (current != nr) {
for (var i = 0; i<pic.length; i++) {
if (nr != i) {
pic[i].hold();
} else {
pic[i].go();
current = i;
}
}
}
}
function nextLoaded() {
loaded++;
if (loaded>=pic.length) {
randPic();
}
}
function nextPic(nr) {
// Blendet ein zufälliges Bild verzögert ein
clearInterval(IV);
do {
var v = int(Math.random()*pic.length);
} while (v == nr);
IV = setInterval(function () { showPic(v);}, timeout);
}
function randPic() {
// Blendet ein zufälliges Bild ein
clearInterval(IV);
do {
var v = int(Math.random()*pic.length);
} while (v == current);
showPic(v);
}