View Single Post
 09-26-2008, 04:10 PM #4 lordofduct Senior Member     Join Date: Feb 2008 Location: West Palm Beach, FL Posts: 3,883 fl.motion.Color.interpolateColor(fromColor:uint, toColor:uint, progress:Number):uint ActionScript Code: ```public static function interpolateColor(fromColor:uint, toColor:uint, progress:Number):uint     {         var q:Number = 1-progress;         var fromA:uint = (fromColor >> 24) & 0xFF;         var fromR:uint = (fromColor >> 16) & 0xFF;         var fromG:uint = (fromColor >>  8) & 0xFF;         var fromB:uint =  fromColor        & 0xFF;         var toA:uint = (toColor >> 24) & 0xFF;         var toR:uint = (toColor >> 16) & 0xFF;         var toG:uint = (toColor >>  8) & 0xFF;         var toB:uint =  toColor        & 0xFF;                 var resultA:uint = fromA*q + toA*progress;         var resultR:uint = fromR*q + toR*progress;         var resultG:uint = fromG*q + toG*progress;         var resultB:uint = fromB*q + toB*progress;         var resultColor:uint = resultA << 24 | resultR << 16 | resultG << 8 | resultB;         return resultColor;       }``` it has an interpolate method that with interpolate across a range from a start colour to an end colour. You can pass a random value in it to get a range. Just keep in mind what occurs when you interpolate. Say you start from 0x00000 and go to 0xFFFFFF. You're only gonna get tints of black. Where as starting at 0xFF0000 and going to 0x0000FF is going to go from red to purple to blue. Your method isn't working because the value for a colour is strongly based on the positions of values. It's a 24-bit value where the first 8 bits represent red, the next 8 bits represent green, and the last 8 bits represent blue. to add one level of tint to green you don't add 1, you add 256. __________________ www.lordofduct.com - come read my blog! If you want to know how to program, take a math class, take a lot of math classes! Last edited by lordofduct; 09-26-2008 at 04:13 PM.