views:

332

answers:

1

I am binding a checkbox to a property on a control. Everything is fine, but I need to bind the checkbox to another property, and the value needs to be the opposite of chkbox.checked.

BindingUtils.bindProperty(obj, "propertyBool", checkBox, "selected");

I need something like this...

BindingUtils.bindProperty(obj, "propertyBool", checkBox, "!selected");

but I'm not sure how to go about doing it in AS3.

+4  A: 

You can use BindingUtils's bindSetter method. It works pretty much the same as the bindProperty method, but it fires a method which takes the value of the property you're binding to as an argument.

Something like the following:

BindingUtils.bindSetter(propertyBoolListener, checkBox, "selected");

private function propertyBoolListener(value:Boolean):void
{
    obj.propertyBool = !value;
}
Ross Henderson