I am sure there were many times in the past that you would have wanted to have a function that could return you random colors. Well at least i have faced this problem many times, Mostly when i am giving a demo for a new component which deals with various color ranges.
Following is the code to generate Random colors:
1 2 3 4 5 6 7 8 9 | private var redBias:Number = 0xFF; private var greenBias:Number = 0xFF; private var blueBias:Number = 0xFF; private function getRandomColor():uint{ var ct:ColorTransform = new ColorTransform(1,1,1,1,Math.random()*redBias, Math.random()*greenBias, Math.random()*blueBias); var color:uint = ct.color; return color; } |
you can also modify the above code to return you a range in a specific color range this can be done by making any 2 colors constant instead of using a random number. Well then enjoy the code and do post in any new cool things that you can do with this piece of code.
for more know-how read the following post : ColorTransform
No related posts.
Tags: color, colorTransform, random, random color



