I’ve got a label in my mxml like this;
<s:Label id="lblChange" text="{_symbol.change>0 ? '+' + _symbol.change:_symbol.change}" />
This works perfectly fine, but I need to replace the binding via curly brackets with BindingUitls, something like this;
_changeWatcher = BindingUtils.bindProperty(lblChange, "text", _symbol, "change");
Again, works fine, but without the if/else case. So I though I could just write a function to do that;
private function checkValue(val:Number):String {
if (val > 0)
return "+"+val;
else
return val as String;
}
and use it as a property in the bindProperty call instead of change;
.bindProperty(lblChange, "text", _symbol, checkValue(_symbol.change));
However, bindProperty seems to accept nothing but strings here. So what way is there to get around this ‘feature’?
Try this: