<mx:Label text="{(item1 as INewsItem).displayName}"/>
For the above code in Flex, I get this warning :
: Data binding will not be able to detect assignments to item1.
Why? How to Fix it?
<mx:Label text="{(item1 as INewsItem).displayName}"/>
For the above code in Flex, I get this warning :
: Data binding will not be able to detect assignments to item1.
Why? How to Fix it?
The warning is displayed because the databinding will not be refreshed automatically when item1
is updated. If you do want this behaviour, then you cannot use this databinding and will have to update the label text manually when item1
is changed.
Thanks Prutswonder.
Actually item1 is declared as a getter,
like this :
public function get item1()
So, I had to prepend it like this :
[Bindable] public function get item1()
If you define a [Bindable] function get item1()
you'll also need to define a function set item1()
, otherwise Flex wouldn't know when to dispatch a change event. Or you could manually dispatch the change event:
[Bindable(event="item1Change"]
public function get item1() { return ... }
And whenever something on item1 changes you dispatch an event:
dispatchEvent(new Event("item1Change"));