Hopefully an easy one. Please try the simple test case below. Select
one or more items, enter a new label and click "Update". You can
optionally select the checkbox to force an invalidateNow after the
update, but either way, the list doesn't refresh. If you scroll down
and up, then they refresh.
How can I get my TileList to refresh when data changes?
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<30; i++)
{
dataCollection.addItem({id: i, data:
"element " + i});
}
list.invalidateList();
}
private function update():void
{
// save selection
var indices:Array = list.selectedIndices;
for (var i:int=0; i<indices.length; i++)
{
var obj:Object =
dataCollection.getItemAt(indices[i]);
obj.data = val.text;
}
list.invalidateList();
if ( doValidateNow.selected )
list.validateNow();
}
]]>
</mx:Script>
<mx:ArrayCollection id="dataCollection" />
<mx:VBox height="400">
<mx:HBox>
<mx:TextInput id="val" />
<mx:Button label="Update" click="update()" />
<mx:CheckBox id="doValidateNow" label="Do a validateNow"
/>
</mx:HBox>
<mx:TileList id="list" allowMultipleSelection="true" width="250"
height="150"
change="{ val.text = list.selectedIndices.length > 0 ? '' :
list.selectedItem.data}"
columnCount="1" labelField="data"
dataProvider="{dataCollection}" >
<mx:itemRenderer>
<mx:Component>
<mx:Label text="{data.data}" />
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
</mx:VBox>
</mx:Application>