Enable and disable checkbox?

Hi …

Okay I just need advise on how to make this simple instead of what I have now…it’s working very well …perhaps someone can shed light on me how to make it as more elegants code…because it gonna give me the problemo when Im dealign with 2 objects what about 4…to 6 objects my code will more longer …any tips are really appreciated…



cbCC.visible = false;
cbBCC.visible = false;
attachClip.visible = false;

//cc and bcc are actually instance name for the checkbox flash component

var checkBoxArr:Array = new Array(cc,bcc);
var cblen:int = checkBoxArr.length;

for(var i:int=0;i<cblen;i++){
    var cBox:CheckBox = checkBoxArr* as CheckBox;
    cBox.addEventListener(Event.CHANGE, checkBoxChange);
}

function checkBoxChange(e:Event):void{
    var cb:CheckBox= e.target as CheckBox;
    
//how to make simple for this portions instead I have to determine one by one here...
    if(cb.name == "cc"){
        if(cb.selected == true){
            cbCC.visible = true;
            bcc.mouseEnabled = false;
            attachClip.visible = true;
        }else if(cb.selected == false){
            cbCC.visible = false;
            bcc.mouseEnabled = true;
            attachClip.visible = false;
        }
    }
    if(cb.name == "bcc"){
        if(cb.selected == true){
            cbBCC.visible = true;
            cc.mouseEnabled = false;
            attachClip.visible = true;
        }else if(cb.selected == false){
            cbBCC.visible = false;
            cc.mouseEnabled = true;
            attachClip.visible = false;
        }
    }

}



Tq