supponiamo che il tuo rettangolone si chiami come nome istanza "face"
sul frame avrai
codice:
// blendRGB uses this Number prototype
// converts a (hex) number to r,g, and b.
Number.prototype.HEXtoRGB = function(){
return {rb:this >> 16, gb : (this >> 8) & 0xff, bb:this & 0xff};
};
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;
};
// array of colors to cycle through
colorSeletction = [0x006699, 0x663333, 0xCC6666, 0x669900];//questi sono i tuoi colori
// value to determine tweening between
// 2 colors. 0 is fully the first color
// 1 is fully the second color
colorTween = 0;
// speed for how fast the tween will progress
tweenSpeed = .05;
// color object to control the face movieclip
faceColor = new Color(face);
// enterFrame to handle face's color blend
face.onEnterFrame = function(){
// increase tween by speed
colorTween += tweenSpeed;
// check to see if the color tween has passed
// 1 or 0, if so, offset it to be back in
// range and shift the elements in the array
// to allow for a blend with a new color
if (colorTween > 1){
colorTween--;
colorSeletction.push(colorSeletction.shift());
}else if (colorTween < 0){
colorTween++;
colorSeletction.unshift(colorSeletction.pop());
}
// use blend RGB to blend between the first two
// elements in the color array. The previous if
// statements keeps them changing when the color
// tween reaches the end of a tween (1 or 0)
faceColor.blendRGB(colorSeletction[0], colorSeletction[1], colorTween);
};
Ciao