Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex binding in AS3 - Negate boolean value

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.

like image 904
DoorMat Avatar asked Jan 26 '10 20:01

DoorMat


1 Answers

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;
}
like image 189
Ross Henderson Avatar answered Oct 02 '22 13:10

Ross Henderson