ありがとうございました。私はついにこれを解決しました。私のスパークリストのサブクラスでは、set dataProviderをオーバーライドし、weak参照イベントリスナーをdataProviderにアタッチします。
override public function set dataProvider(theDataProvider:IList):void
{
super.dataProvider = theDataProvider;
dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChange, false, 0, true);
}
次に、イベントハンドラで、移動したアイテムが以前に選択されていた場合は、それを再選択します。 CollectionEventKind.MOVE
ケースを参照してください。
private function onCollectionChange(theEvent:CollectionEvent):void
{
if (theEvent.kind == CollectionEventKind.ADD)
{
// Select the added item.
selectedIndex = theEvent.location;
}
else if (theEvent.kind == CollectionEventKind.REMOVE)
{
// Select the new item at the location of the removed item or select the new last item if the old last item was removed.
selectedIndex = Math.min(theEvent.location, dataProvider.length - 1);
}
else if (theEvent.kind == CollectionEventKind.MOVE)
{
// If the item that moved was selected, keep it selected at its new location.
if (selectedIndex == theEvent.oldLocation)
{
selectedIndex = theEvent.location;
}
}
}
出典
2011-01-31 22:14:41
Max
コード例を投稿できますか? –
あなたはスパークリストコンポーネントのselectedIndices:Vectorに新しいインデックスまたはアイテムを割り当てることはできません。またはselectedItems:Vector。