开发者

stack overflow on XMLListCollection collectionEvent

I'm working on a Flex 3 project, and I'm using a pair of XMLListCollection(s) to manage a combobox and a data grid.

The combobox piece is working perfectly. The XMLListCollection for this is static. The user picks an item, and, on "change", it fires off an addItem() to the second collection. The second collection's datagrid then displays the updated list, and all is well.

The datagrid, however, is editable. A further complication is that I have another event handl开发者_开发技巧er bound to the second XMLLIstCollection's "change" event, and in that handler, I do make additional changes to the second list. This essentially causes an infinite loop (a stack overflow :D ), of the second lists "change" handler.

I'm not really sure how to handle this. Searching has brought up an idea or two regarding AutoUpdate functionality, but I wasn't able to get much out of them. In particular, the behavior persists, executing the 'updates' as soon as I re-enable, so I imagine I may be doing it wrong. I want the update to run, in general, just not DURING that code block.

Thanks for your help!


Trying to bind the behaviour to a custom event rather than the CHANGE event.

I.e. do what you are doing now, but dispatch and handle a custom event to do the work.


Have you considered using callLater? Does direct manipulation of XMLListCollection's source XMLList have the same results? Have you considered something like:

private function changeHandler( event:Event ):void
{
    event.target.removeEventListener( event.type, changeHandler );

    // your code here.

    event.target.addEventListener( event.type, changeHandler );
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜