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