I have a nice working fade-in/out script, which i try to adapt for loading swfs.
Unfortunately the preloader part does not work, but i dont know why.
I only guess it has to do with the way i have to reference to the loading container(s), which has a new name for every swf to load: MC1, MC2,…
function swapClip() {
if (currentClip == "undefined" || currentClip._alpha>1) {
currentClip._alpha--;
} else {
currentClip._visible = false;
if (eval(newOne)._alpha<100) {
eval(newOne)._alpha++;
} else {
if (eval(newOne)._alpha == int(eval(newOne)._alpha)) {
clearInterval(swapInter);
currentClip = newOne;
} else {
eval(newOne)._alpha += 15;
}
}
}
}
for (var i = 1; i<=4; i++) {
var ref:MovieClip = this.NAVI["BTN"+i];
ref.ID = i;
ref.onRollOver = function() {
if (this != _root.clicked) {
this.gotoAndStop("OVER");
}
};
ref.onRollOut = ref.onReleaseOutside=function () {
if (this != _root.clicked) {
this.gotoAndStop("UP");
}
};
for (var j = 1; j<=4; j++) {
this["MC"+j].id = j;
ref.onRelease = function() {
if (this != _root.clicked) {
if (this.ID == 1) {
createEmptyMovieClip("MC1", 1);
MC1.loadMovie("SWF1.swf", 10);
ladestatus();
MC1._alpha = 0;
MC1._x = 0;
MC1._y = 0;
currentClip = newOne;
clearInterval(swapInter);
newOne = MC1;
swapInter = setInterval(swapClip, 5);
}
if (this.ID == 2) {
createEmptyMovieClip("MC2", 2);
MC2.loadMovie("SWF2.swf", 10);
ladestatus();
MC2._alpha = 0;
MC2._x = 0;
MC2._y = 0;
currentClip = newOne;
clearInterval(swapInter);
newOne = MC2;
swapInter = setInterval(swapClip, 5);
}
if (this.ID == 3) {
createEmptyMovieClip("MC3", 3);
MC3.loadMovie("SWF3.swf", 10);
ladestatus();
MC3._alpha = 0;
MC3._x = 0;
MC3._y = 0;
currentClip = newOne;
clearInterval(swapInter);
newOne = MC3;
swapInter = setInterval(swapClip, 5);
}
if (this.ID == 4) {
createEmptyMovieClip("MC4", 4);
MC4.loadMovie("SWF4.swf", 10);
ladestatus();
MC4._alpha = 0;
MC4._x = 0;
MC4._y = 0;
currentClip = newOne;
clearInterval(swapInter);
newOne = MC4;
swapInter = setInterval(swapClip, 5);
}
this.gotoAndStop("PRESS");
_root.clicked.gotoAndStop("UP");
_root.clicked.useHandCursor = true;
_root.clicked = this;
this.useHandCursor = true;
}
};
}
}
loader._visible = false;
//-------------------------------------------------
preload = function () {
loader.onEnterFrame = function() {
loaded = this["MC"+j].getBytesLoaded();
totoload = this["MC"+j].getBytesTotal();
if (loaded>=10) {
loader._visible = true;
percent = Math.round(loaded/totoload*100);
this.prozentanzeige.text = percent+" % geladen";
this.balken._xscale = percent;
if (percent>=100) {
delete this.onEnterFrame;
this._visible = false;
}
}
};
};
//-------------------------------------------------
stop();
Thanks for help!