The way to do this is to use bindSetter . This is also the way it is done behind the scenes when MXML in your example is converted to ActionScript before compilation.
// assuming the itemName property is defined on this: BindingUtils.bindSetter(itemNameChanged, this, ["itemName"]); // ... private function itemNameChanged( newValue : String ) : void { myBtn.label = newValue; myBtn.visible = newValue != null; }
... except that the code generated by converting MXML to ActionScript is longer since it needs to be more general. In this example, he most likely generated two functions: one for each binding expression.
source share