This is a very useful function in the Flex’s BindingUtils class.
It allows to execute a function everytime the associated (and bindable) property change it’s value.
Here’s the syntax:
BindingUtils.bindSetter(bindFunction, hostObject, “propertyName”);
And the example…
private var:hostObject:MyObject;
private function init():void {
BindingUtils.bindSetter(calculate, hostObject, "squareRoot");
}
private function calculate(number:Number):void {
// ... calculate the square root here...
}
So, in the example above:
Every time the property with name squareRoot, inside the object hostObject has a new value assigned, the function calculate will be called.
Remarks:
- squareRoot is a variable of type Number
- The value of squareRoot will be passed as a parameter to the calculate function.