CheckBoxes allow any number to be checked. In this example the check boxes are used to select a color for the flower. Only 8 colors are possible: 2x2x2 =red (0xFF0000), green (0x00FF00), blue(0x0000FF), yellow (0xFFFF00), agua(0x00FFFF), magenta(0xFF00FF), white(0xFFFFFF) and black(0x000000)
The code is shown below:
chkRed.addEventListener(Event.CHANGE,changeColor);
chkGreen.addEventListener(Event.CHANGE,changeColor);
chkBlue.addEventListener(Event.CHANGE,changeColor);
function changeColor(e:Event):void {
var colorT:ColorTransform = new ColorTransform();
var red:int=0; //initial value
var green:int=0;
var blue:int=0;
if(chkRed.selected) red=255;
if(chkGreen.selected) green=255;
if(chkBlue.selected) blue=255;
colorT.color = (red*256*256)+(green*256)+blue; //RGB value
flower.colorArea.transform.colorTransform = colorT; //change the color of the flower
var s:String=colorT.color.toString(16);
while(s.length<6) {
s="0"+s; //make the RGB color a length of 6
}
s=s.toUpperCase();
lblColor.text=s;
} //changeColor
Download the movie