Changing a Color in ActionScript

We will change the color of the flower to a random color when we click the button:

Get Adobe Flash player

The code is shown below:

function changeColor(e:MouseEvent):void {
   var colorT:ColorTransform = new ColorTransform();
   colorT.color = randomColor();
   flower.colorArea.transform.colorTransform = colorT; //change the color of the flower
} //changeColor
function randomColor(): int {
   var red:int=Math.random()*256;  
   var green:int=Math.random()*256;
   var blue:int=Math.random()*256;
   return (red*256*256)+(green*256)+blue; //RGB value
} //randomColor
Download movie

NEXT: A Random Color with a lighter and darker shading