una cosa del genere????
codice:
MovieClip.prototype.fadeColor = function (finalColor, finalAlpha, speed, callback) {
this.percentage = 0;
clearInterval (this.fadeInt);
this.tmpColor = new Color (this);
this.deltaAlpha = finalAlpha - this._alpha;
this.startAlpha = this._alpha;
this.fade = function (target_MC) {
if (target_MC.percentage >= 1) {
target_MC.startColor = finalColor;
target_MC._alpha = finalAlpha;
clearInterval (target_MC.fadeInt);
callback ();
} else {
target_MC.percentage += speed;
target_MC.tmpColor.blendRGB(target_MC.startColor, finalColor, target_MC.percentage);
if (target_MC.deltaAlpha != 0) {
target_MC._alpha = target_MC.startAlpha + (target_MC.deltaAlpha * target_MC.percentage);
}
}
}
this.fadeInt= setInterval (this.fade, 40, this);
}
// Hide the function and the related properties to the for in loops
ASSetPropFlags(MovieClip.prototype, "fadeColor", 1, 0);
Color.prototype.blendRGB = function(c1,c2,t){
if (arguments.length == 2){
t = c2;
c2 = this.getRGB();
}
if (t<-1) t=-1;
else if (t>1) t=1;
if (t<0) t=1+t;
c1 = c1.HEXtoRGB();
c2 = c2.HEXtoRGB();
var ct = (c1.rb+(c2.rb-c1.rb)*t) << 16 | (c1.gb+(c2.gb-c1.gb)*t) << 8 | (c1.bb+(c2.bb-c1.bb)*t);
this.setRGB(ct);
return ct;
};
Number.prototype.HEXtoRGB = function(){
return {rb:this >> 16, gb:(this >> 8) & 0xff, bb:this & 0xff};
};
richiami così per i tuoi clip
codice:
// PARAMETERS
// finalColor = the destination colour
// finalAlpha = the destination Alpha
// speed = values admitted are between 0 and 1 (ex. 0.05, 0.10 or 0.15)
// callback = optional function to be called at the end of the fading
// USAGE
// create a clip named "myMovieClip_mc" and the buttons "sample1_btn" and "sample2_btn"
// attach the following code to frame 1
// set the starting color (only the first time);
// if not set, the default is black
myMovieClip_mc.startColor = 0x009933
// set callback functions to be called when fading is finished
function test () {
trace ("fading finished");
}
// change the movieClip to a semi-transparent yellow
myMovieClip_mc.fadeColor (0x009933, 50, .05, test);
// change the movieClip to an opaque azure, slowly
//myMovieClip_mc.fadeColor (0x0191C7, 100, .02, test);