I had the exact problem you did, and also someone asked a similiar question 
last week and I responded, I would check that response as it applies here as 
well

Basically, you are out of luck. ItemChangeEffect does not work with sort or 
filter. You will need to create your own custom component. Adobe has an example 
of this, the code  is pretty special case, but might help you get started 

http://www.adobe.com/devnet/flex/samples/flex_store/



___________________________________________________________________________________________
From: [email protected] [mailto:[email protected]] On Behalf 
Of cbs1918
Sent: Tuesday, December 01, 2009 4:51 PM
To: [email protected]
Subject: [flexcoders] TitleList Sort Data - Animation

  
I want to have a TitleList with several elements. Then I want to have 
components to filter the data, when the data changes the items in the TitleList 
should animate into place. When I enable drag/drop on the TitleList and move 
elements the animation behaves as expected. However, when I sort/change the 
array the animation does not happen. After sorting the array I've found that if 
I call invalidateList() on the TitleList then the items update based on the new 
order of the array but they just appear in their new position they do not 
animate. What am I doing wrong or need to update? I've built a scaled down 
version and provided the code below.

Sample.mxml
-----------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
applicationComplete="initApp();">
<mx:Script>
<![CDATA[
[Bindable]
protected var _arrData:Array;

protected function initApp():void {
_arrData = new Array();
_arrData.push( new SampleDataModel("Item 1") );
_arrData.push( new SampleDataModel("Item 2") );
_arrData.push( new SampleDataModel("Item 3") );
_arrData.push( new SampleDataModel("Item 4") );
_arrData.push( new SampleDataModel("Item 5") );
_arrData.push( new SampleDataModel("Item 6") );
_arrData.push( new SampleDataModel("Item 7") );
_arrData.push( new SampleDataModel("Item 8") );
}

protected function sortItems():void {
_arrData.push(_arrData.shift());
titleLst.invalidateList();
}
]]>
</mx:Script>
<mx:Button label="Sort Items" click="sortItems();" />
<mx:TileList id="titleLst" dataProvider="{_arrData}" rowCount="2" 
columnCount="2" itemRenderer="SampleDisplayItem" width="250" height="100" 
dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
<mx:itemsChangeEffect>
<mx:DefaultTileListEffect fadeOutDuration="250" fadeInDuration="350" 
moveDuration="500" />
</mx:itemsChangeEffect>
</mx:TileList>
</mx:Application>

SampleDataModel.as
------------------
package 
{
import flash.events.EventDispatcher;

[Bindable]
public class SampleDataModel extends EventDispatcher
{
public var title:String = "";

public function SampleDataModel(...rest) 
{
if (rest.length > 0) {
title = rest[0];
}
}

}

}

SampleDisplayItem.mxml
----------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="125" height="100">
<mx:Label text="{data.title}" />
</mx:Canvas>

Reply via email to