Aldonline

mx:Bindings on Steroids

OK. The title is way too much.
This is just runtime binding ;)

Problem

You need to setup a binding on runtime, where the properties of the binding are themselves dynamically binded and can be swapped. This is currently not possible with mx:Binding as it is evaluated at compile time.

Solution

Use the RuntimeBinding tag, which uses the same semantic as the mx.bindings.BindingUtils.bindSetter and mx.bindings.BindingUtils.bindProperty methods.

<binding:RuntimeBinding 
  site="{targetObject}" 
  prop="targetPropertyName" 
  host="{hostObject}"
  chain="label.color"
  />

You can also pass a reference to a setter function and/or specify a different value for commitOnly:

<binding:RuntimeBinding 
  site="{setValue}"
  host="{label}"
  chain="text"
  commitOnly="{true}"
  />

Any of the properties can be swapped at runtime. This will cause the binding to be reevaluated and the internal change watcher to be reset.

This class is part of the BigFlexLib project.