I have a problem with deleting item from a Flex 3.0 beta TileList
component. While a delete item effect is playing and I delete another
item, I get an 'RangeError: Index '8' specified is out of bounds.'
error.   The code works fine if you wait until the effects are
finished before you delete another item. How do you delay processing
until the effects are done?  or is there another solution?

To see the problem, hit the down error twice quickly.

example at:  html://designwithflex.com/deleteprob

Here is my code:

<?xml version="1.0"?>
<!-- dataEffects\CustomTileListEffect.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; xmlns:comp="*" >
 <mx:Script>
      <![CDATA[
          import mx.effects.easing.Elastic;
          import mx.collections.ArrayCollection;
          public var mydata:Array=[
              {name:"A",age:14},
              {name:"B",age:15},
              {name:"C",age:16},
              {name:"D",age:17},
              {name:"E",age:18},
              {name:"F",age:19},
              {name:"G",age:20},
              {name:"H",age:21},
              {name:"I",age:22},
              {name:"J",age:23}];
          [Bindable]
          public var myAC:ArrayCollection = new ArrayCollection(mydata);
          
            private function highchange(event:Event):void {
                var removelist:Array = []; // an array of indexes of
items to remove
                        for (var j:int = 0; j < myAC.length; j++){
                   if (myAC[j].age > high.value) {      
                        removelist.push(j);       // keep index of item
to remove, so that we can remove in next step
                   }
                }
                removelist.sort(Array.DESCENDING | Array.NUMERIC);  //
sort list so that we can start deleting from end of the list         
     
                for (var i:int = 0; i < removelist.length; i++) {
                                        myAC.removeItemAt(removelist[i]);    // 
remove item 
                                }                                
          }                    
        ]]>
    </mx:Script>
<mx:DefaultListEffect id="myDLE" 
        fadeOutDuration="2000" 
        color="0x0044ff"/>
     
    <!-- offscreenExtraColumns and ..Rows should be 2, but '2' causes
items to disappear -->
    <mx:TileList id="tlist" 
        height="450" width="400" 
        fontSize="30" fontStyle="bold"
        columnCount="4" rowCount="3" 
        dataProvider="{myAC}"
        itemRenderer="Thumbnail"
        offscreenExtraColumns="0" 
        offscreenExtraRows="0"    
        dataChangeEffect="{myDLE}"/>

    <mx:HBox >
      <mx:Label text="Highest Value:" />
      <mx:NumericStepper id="high" value="23" minimum="17"
maximum="23" stepSize="1" change="highchange(event)"/>
    </mx:HBox>
</mx:Application>

and Thumnail.mxml:

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

Reply via email to