Have you considered de-incrementing the loop? Take the last one first then the compression would not change the lesser values. I think this might be more computationally more efficient if the array was larger than 50.
 
----- Original Message -----
From: wesflex73
Sent: Sunday, May 01, 2005 11:47 AM
Subject: [flexcoders] AS help. Multi deleting from a list.

I am sure there is an easy answer for this but I have tried a few
things and not sure where to go from here. I have a list that is
populated from an array in a function.

<mx:List id="myStateList" dataProvider="{statesList.states}"
multipleSelection="true" />
                                   

The array in the list is states:

AZ
CA
NV
MD
NY

I would like to delete multiple items with one click of a button. So
if I select CA and MD, I would like to delete them from the list.

My button has this call.

<mx:Button label="Remove States" click="statesList.dStates
(myStateList.selectedIndices)"/>
                                   
That returns an array of (1,3)

My Actionscript page (statesList) has this function.

function dStates(delState:Array):Void {
           
              for ( var i = 0; i < delState.length; i++){
                     states.removeItemAt(delState[i]);
                    }
}

But what happens is that this will delete CA and NY. I understand why
this is happening (because states is getting reset and the second
time through the loop, NY is in the 3rd position of the array) so how
else can I do this.

Thank you for any help.





Yahoo! Groups Links

Reply via email to