Color Morph

A very simple prototype to morh a Color object’s color into a provided RGB value, again using my own easing formula. This once again proves that it can be used to ease almost anything.


 Color.prototype.morphTo = function(R, G, B, A){
     aux = _root.createEmptyMovieClip("__colormorph",-999);
     aux.ref = this;
     aux.onEnterFrame = function(){
         curColor = this.ref.getTransform();
         curra = curColor.ra;
         curga = curColor.ga;
         curba = curColor.ba;
         curaa = curColor.aa;
         this.ref.setTransform({ra:R-(R-curra)/1.1, ga:G-(G-curga)/1.1, ba:B-(B-curba)/1.1, aa:A-(A-curaa)/1.1});
     }
 }
 

Example demonstrating this prototype:

[swf=http://www.voetsjoeba.com/lab/view/colorfade.swf]width=760 height=420[/swf]

Source: http://www.voetsjoeba.com/lab/source/colorfade.fla