recuperation checkbox ActionScript3
Bonjour,
je viens de commencer à apprendre l'AS 3 et le flex donc completement newbie !!
J'ai un soucie pour récupérer une liste de checkbox créer precedemment dans une fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
//CREATION LISTE CHECKBOX
private function initList():void{
var model:StructureFiche = new StructureFiche();
this.listeModules = model.getStructureArray();
var checkAll:CheckBox = new CheckBox();
checkAll.label = "Selectionner tout";
checkAll.addEventListener('click', checkAllBox);
this.formCheck.addChildAt(checkAll, 0);
for(var i:int = 0; i <= this.listeModules.length - 1; i++){
var check:CheckBox = new CheckBox();
check.label = 'M' + (i + 1) + " " + this.listeModules[i].libelle;
check.id = i.toString();
check.name = "checkModule";
check.addEventListener('click', checkTheBox);
this.formCheck.addChildAt(check, i+1);
}
PopUpManager.centerPopUp(this);
} |
j'ai la checkbox 'checkAll' qui me permet de checker toute les checkbox.
l'eventlistener :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
private function checkAllBox(event:MouseEvent):void{
if(event.target.selected){
this.listCheck.removeAll();
for(var i:int = 0; i <= this.listeModules.length - 1 ; i++){
this.listCheck.addItem(i.toString());
//RECUP CHECKBOX SOUS FORME DE DISPLAYOBJECT
var checkBox:CheckBox = new CheckBox();
this.formCheck.getChildAt(i+1);
}
}else{
this.listCheck.removeAll();
}
} |
Je récupère mes checkbox sous forme de displayObject et donc je n'ai pas acces a la propriété selected.
Quelqu'un pourrais m'expliquer comment acceder a la propriété selected ?
Merci.
EDIT :
Problème résolu :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
private function checkAllBox(event:MouseEvent):void{
this.listCheck.removeAll();
var data:* = this.formCheck.getChildren();
for(var j:int = 1 ; j <=data.length - 1; j++ ){
if(data[j].id != "button"){
if(!event.currentTarget.selected){
data[j].selected = false;
}else{
data[j].selected = true;
this.listCheck.addItem(j.toString());
}
}
}
if(this.listCheck.length > 0){
this.imprimer.enabled = true;
}
else{
this.imprimer.enabled = false;
}
} |