Please try this very simple example below and let me know if you get the same behavior. Select some or all items in the tile list and click the test button. Try the same but with the checkbox selected. Do you see the difference?

If you save off a TileList's selectedIndices, clear the data provider, clear the selectedIndices, then re-populate the data provider and re-apply the same selections, the setting of the selectedIndices fails.

Does anyone know a workaround?  Alex?

Can someone with moxie beat2 tell me if it still behaves this way?

thanks
charles


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
        applicationComplete="appInit()">
        <mx:Script>
                <![CDATA[
                        import mx.collections.ArrayCollection;
                        private function appInit():void
                        {
                                setData()
                        }
                        private function setData():void
                        {
                                for (var i:int=0; i<3; i++)
                                {
                                        dataCollection.addItem(new String(i));
                                }
                                list.invalidateList();
                        }
                        private function doTest():void
                        {
                                // save selection
                                var indices:Array = list.selectedIndices;
status.text = "Before: SelectedIndex: " + list.selectedIndex + "\n"; status.text += " SelectedIndices: " + indices.join(" ") + "\n";
                                
                                // simulate delete all then add back
                                dataCollection.removeAll();
                                if ( clearData.selected )
                                        list.selectedIndices = new Array();
                                list.invalidateList();
                                setData();
                                
                                // restore selection
                                list.selectedIndices = indices.reverse();
                                
                                status.text += "\n";
                                status.text += "After: SelectedIndex: " + 
list.selectedIndex + "\n";
status.text += " SelectedIndices: " + list.selectedIndices.join(" ") + "\n";
                        }
                ]]>
        </mx:Script>
        <mx:VBox height="400">
                <mx:HBox>
                        <mx:Button label="Test Selections" click="doTest()" />
<mx:CheckBox id="clearData" label="Clear selections inbetween delete/add" />
                </mx:HBox>
<mx:TileList id="list" allowMultipleSelection="true" width="250" height="150" >
                        <mx:dataProvider>
                                <mx:ArrayCollection id="dataCollection" />
                        </mx:dataProvider>
                </mx:TileList>
                <mx:Panel title="Selection Info">
                        <mx:TextArea id="status" width="250" height="150" />
                </mx:Panel>
        </mx:VBox>
        
</mx:Application>

Reply via email to