Thanks all for your help.
 
I went with the states.removeItemAt(delState[i]-i); solution since it was the quickest to implement. I did have to add delStates.sort() in the beginning of the function since selectedIndencies() could be set to (1,0,4,3) depending on which order you select the states in the list. 
 
Darron thanks for the idea of slice and dispatchEvent. I will look into that when I have more time.
 
Thanks.

"Darron J. Schall" <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:

> 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.

If you're really worried about the efficiency you shouldn't use
removeItemAt, but rather just call:

states.splice( index, 1 );

That will delete a single element at a specified index.  Then, when
you're done deleting all elements, you'll want to dispatch a
modelChanged event so that all of the listening elements to the data
provider get updated:

states.dispatchEvent({type:"modelChanged"});

Doing it the above way will avoid the modelChanged event being
dispatched for every element removal, avoiding all of that extra
processing.  Rather, you can "batch" your changes via splice then notify
all of the listeners at the end.

And yes, looping over the elements backwards would be slightly faster
than subtracting i again each iteration..

-d


Do you Yahoo!?
Make Yahoo! your home page

Yahoo! Groups Links

Reply via email to