Binding to Getter/Setter methods
This is a tough one to write about. I can’t say I agree with the outcome, as it’s overly complex. But it’s what there is:
The problem:
I had to have a “label” on an object that was read-only but bindable. Basically, this means that I had to write a getter method for label. But as I found out, the flex compiler does not enable binding on read-only properties. This means if you create a getter method without a setter method binding will not fire. At all. Ever.
Even if you define your class as [Bindable]. So that I’m clear on this:
READ-ONLY PROPERTIES ARE NOT BINDABLE!
Okay, now that I’ve said that clearly. Let me tell you how I solved this. Recall I called it ugly.
All I had to do was create a setter method for the property which was private. That way external interfaces won’t be misled in believing they can “set” a value on the property (thus maintaining the read-onlyness).
Nice, huh?
Leave a Reply