I recently had an issue where I could not get binding in one of my custom components to work. I was simply testing some things out and has a label tag bound to the length property on one of my data model objects. The problem was that the text was not being updated.
< mx:Label text='{obj.anotherObject.yetAnotherObject.length}' />
I initially thought that it might be due to the fact that this object was inherited and the bindable stuff was in the parent class, but it didn’t change when I moved the stuff into the class itself. Next up, blame it on the fact that it was a custom binding job with a read only property:
[Bindable("lengthChanged")]
public function get length():int
{
return _length;
}
private function addObject(obj:Object, id:String):void
{
_objects[id] = obj;
_length++;
dispatchEvent(new Event("lengthChanged"));
}
(Or something like that, the code has since changed).
This too turned out to be not the case. I changed the property to be a simple public variable on a [Bindable] class. No joy.
I finally figured out that I had to cast the second to last value in the property chain to its proper type. This allowed the compiler to pick up the proper events and add the proper event listeners (or whatever other data binding voodoo that it does).
< mx:Label text='{YetAnotherObjectType(obj.anotherObject.yetAnotherObject).length}' />
Works like a charm.