Using BindingUtils Chain Value for Nested Property Bindings

Written by

In my previous post I mentioned using BindingUtils to update a View with data from a Model. One problem I found were my bindings within nested properties i.e. accessing a value within an Object in a Class, were not firing. The sequence would be model.data.selectedValue.value and setting up the binding in ActionScript I had used incorrectly:

1
2
// Incorrect
BindingUtils.bindProperty( view.my_txt, "text", model.data.selectedValue, "value" );

The correct way to approach this is to actually set a chain of bindable properties as String values within an Array.

A non-empty Array containing a combination of the first two options that represents a chain of bindable properties accessible from the host. For example, to bind the property host.a.b.c, call the method as: bindProperty(host, [“a”,”b”,”c”], …).

So the above correctly written would become:

1
2
// Correct
BindingUtils.bindProperty( view.my_txt, "text", model, ["data", "selectedValue", "value"] );

A small oversight that could easily be made.

Comments