List绑定Array并剔除Array项的bug

List绑定Array并删除Array项的bug

做了一个组件,用途是从左边的List中选择某些项,点击按钮,添加这些项到右边List,并将其从左边List删除。

两个List的数据源都是Array。用splice方法删除选中的项。

 

问题: 在选择较多项时(大概40+),报如下错误:

 

Error: Invalid index: '68'.
    at mx.collections::ListCollectionView/http://www.adobe.com/2006/flex/mx/internal::getBookmark()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1021]
    at ListCollectionViewCursor/get bookmark()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1699]
    at mx.controls.listClasses::ListBase/updateDisplayList()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3711]
    at mx.controls::List/updateDisplayList()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\controls\List.as:1005]
    at mx.controls.listClasses::ListBase/validateDisplayList()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3344]
    at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:622]
    at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:695]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8744]
    at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8684]

 

找了很久,也不知道问题在哪儿。(如果你知道,请告诉我,多谢)

 

就用ArrayCollection 替换了Array作为数据源,相应的方法替换为removeItemAt。

没错误了。。。