thank you!  that's the solution... I knew I was over thinking it.

Here is what worked for anyone interested:  - Kevin

(In this case, if your fldValue is a boolean value it doesn't bother comparing.)

public function set fldValue(myFldValue:Object):void{
  _fldValue = myFldValue;
  if(_fldValue is Boolean){
    this.selected = _fldValue;
  }else{
    if(_fldValue == value){
     this.selected = true
    }else{
     this.selected = false;
    }
  }
}




On Nov 7, 2007, at 12:03 PM, Tracy Spratt wrote:


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