0 Replies Latest reply on Oct 15, 2009 3:09 PM by GuilhermePacheco

    TileList Effect

    GuilhermePacheco

      Hi,

       

      I have a TileList, and I want to change 2 items by click. The effect to next items works fine, but the effect for de prev items fail.

      How can I make this effect works? (Sorry if my english is bad)

       

      Here is my code:

       

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="{init();}" verticalAlign="middle">
      
           <mx:Script>
                <![CDATA[
                     import mx.collections.ArrayCollection;
                     
                     [Bindable]
                     private var provider:ArrayCollection = new ArrayCollection();
                     private var myData:Array = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J");
                     private var firstIndex:int = 0;
                     
                     private function init():void {
                          for(var i:int; i < 4; i++)
                               provider.addItem(myData[i]);
                     }
                     
                     private function prev():void {
                          if(firstIndex > 1) {
                               for(var i:int; i < 2; i++) {
                                    provider.removeItemAt(provider.length - 1);
                               }
                               for(i = 0; i < 2; i++) {
                                    provider.addItemAt(myData[--firstIndex], 0);
                               }
                          }
                     }
                     
                     private function next():void {
                          if(firstIndex < 5) {
                               for(var i:int; i < 2; i++) {
                                    provider.removeItemAt(0);
                               }
                               for(i = 0; i < 2; i++) {
                                    provider.addItem(myData[firstIndex + 4]);
                                    firstIndex++;
                               }
                          }
                     }
                ]]>
           </mx:Script>
           
           <mx:DefaultTileListEffect id="effect" fadeOutDuration="500" moveDuration="500" fadeInDuration="500"/>
           
           <mx:Button label="&lt;" click="{prev();}"/>
           <mx:TileList dataProvider="{provider}" id="tileList" rowCount="1" columnCount="4" itemsChangeEffect="{effect}"/>
           <mx:Button label="&gt;" click="{next();}"/>
           
           
           
      </mx:Application>
      
       
      

       

       

      Thanks for help.