开发者

binding to arraycollection does not work

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??


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜