Flex binding in AS3 - Negate boolean value
actionscript-3, apache-flex, binding, boolean, checkbox
Solution
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;
}
Problem
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.