A while ago I wrote a Hexadecimal Color Fading Tutorial explaining how to select a single color at any point on a gradient between two specified colors. In that tutorial there was a function which efficiently broke each of the 2 specified colors into their Red, Green and Blue components and then calculated a single new color at a specified point between them.

Approximately 80% of the above code is dedicated to breaking the "hex" and "hex2" hexadecimal colors into their RGB components. Repeatedly calling the above function with the same "hex1" and "hex2" values can be wasteful because the the RGB values are constantly being recalculated and disposed of rather than being stored in variables for quick retrieval.

If you want to create a gradient with a lot of steps or if you want to store your results in an array, you should consider an alternative approach. The following code efficiently creates a gradient of colors between 2 initial hexadecimal values and stores the results in an array.

That's pretty slick. But... What if I want to fade between 3 colors? Or 4 colors? Or 6? Calling the above function multiple times might work but it's wasteful for reasons similar to those mentioned in our first code example.

Once again we can improve performance by consolidating multiple function calls into one streamlined function. The tricky part is finding a way to provide arguments to our function in a manner that's both flexible and convenient.

hi i was just trying your script (cool one) but i cant get it 2 work im pasting it on my action panel on the first frame of the scene (CS3) but when i play it 2 c the swf, i only get the output with the code for the colors but nothing on the SWF… help would be great