views:

78

answers:

1

Hi, I am using flex SDK 3.5. I have model.as and in it i have an ArrayCollection (name it arr_mod) which is Bindable. From my mxml i link to this arr_mod in three places:
1) in DataGrid i set dataprovider={arr_mode} ...
2) in Button i add new item to the arr_mod this way: mx:Button .. click = "{arr_mod.addItem(new Item)}"


3) in textBox i want to add mx:TextBox text="{mySpecialCounterFunc(arr_mod)}" note that in the Script of mxml arr_mod is Bindable as well as in the class definition in model.as

The problem is, that when clicking on button, mySpecialCounterFunc is not called! it should be called, since i use {} and this should listen to changes in arr_mod (a change that was made in the button should cause a new item to be added.. and than the listener to respond).
While The DataGrid is updated correctly!
By the way, if i change arr_mod to simple String or Int it works.. i.e. mySpecialCounterFunc is called
Why??

A: 

I know I've sometimes experienced weird behavior binding to ArrayCollection. When something doesn't work I usually switch away from using MXML binding to putting a direct event listener for CollectionEvent.COLLECTION_CHANGE and doing what I want to do in that event handler. I believe MXML binding is just syntactic sugar for this anyway.

Karthik