MovieClip.prototype.fwechsel1 = function(co){
this.createEmptyMovieClip("emc_"add co, 999);
this["emc_"add co].onLoad = function(){
a=this;
b= a.substr(a.indexOf("emc_")+4);
this.cnt=0;
this.startColor = _root.Farbe1;
this.newColor = _root.Farbe2;
this.col = new Color(_root[b]); // Farb-Objekt
this.col.setRGB(parseInt(this.startColor,16)); // setzen des Startwerts
this.steps = _root.Stufen;
this.r = parseInt(this.startColor.substr(0,2),16); // ermitteln der einzelnen Komponenten des Startwerts
this.g = parseInt(this.startColor.substr(2,2),16);
this.b = parseInt(this.startColor.substr(4,2),16);
this.newR = parseInt(this.newColor.substr(0,2),16); // ermitteln der einzelnen Komponenten des Endwerts
this.newG = parseInt(this.newColor.substr(2,2),16);
this.newB = parseInt(this.newColor.substr(4,2),16);
this.diffR = (this.r - this.newR) / this.steps; // Berechnung der Differenzen
this.diffG = (this.g - this.newG) / this.steps;
this.diffB = (this.b - this.newB) / this.steps;
}
this["emc_"add co].onEnterFrame = function(){
cnt++;
if(cnt < steps) {
this.rgb = _root[b].col.getRGB().toString(16); // aktuelle Farbe auslesen
this.r = parseInt(this.rgb.substr(0,2),16);
this.g = parseInt(this.rgb.substr(2,2),16);
this.b = parseInt(this.rgb.substr(4,2),16);
this.newR = Math.floor(this.r-this.diffR).toString(16);
this.newG = Math.floor(this.g-this.diffG).toString(16);
this.newB = Math.floor(this.b-this.diffB).toString(16);
if(this.newR.length == 1) this.newR = "0" + this.newR;
if(this.newG.length == 1) this.newG = "0" + this.newG;
if(this.newB.length == 1) this.newB = "0" + this.newB;
this.newColString = this.newR + this.newG + this.newB; // neue Farbe zusammensetzen und zuweisen
_root[b].col.setRGB(parseInt(this.newColString,16));
}else{
this.cnt=0;
delete this.onEnterFrame;
delete this;
}
}
}
Warum geht das so nicht?