Don't bind.  Use a setter function for fldValue, then in that setter,
call your logic to update the selected property.

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Kevin
Sent: Wednesday, November 07, 2007 12:05 AM
To: [email protected]
Subject: [flexcoders] Bind Value to Checkbox

 

I would like to bind a non-boolean value to a CheckBox? I can't 
figure out the right way to do this.

I would like to create a custom CheckBox that can accept a string 
value as a property. For example, if my model returns the string 
"apple" then

<util:MyCustomCheckBox value="apple" fldValue="{model.myCustom.fld}" />

In my extended CheckBox code it looks at that fld and then decides 
whether to select the CheckBox or not.

private function getBooleanValue():void{
if(value != fldValue){
selected = false;
}else{
selected = true;
}
}

My problem is with the binding. I can't seem to set it up properly 
so that when the fldValue property changes, the function will get 
called thus changing the selected property. I also tried to create a 
getter function "_booleanValue" and bind the selected property to 
that, but I ran into problems trying to bind getter functions.

The whole binding thing makes my head spin so hopefully this is 
simple fix...

Thanks, Kevin

 

Reply via email to