See if this will work,

// your code
var index:int = list.selectedIndex;
list.dataProvider.addItem(item);
list.validateNow();
moveToIndex(index);

            protected function moveToIndex(index:int):void {
                var point:Point =
list.layout.getScrollPositionDeltaToElement(index);
                if (point) {
                    list.scroller.viewport.horizontalScrollPosition =
point.x;
                }
            }

let me know if it works for you


On Wed, Aug 3, 2011 at 2:27 PM, vigilsolace <sig...@orianmarx.com> wrote:

> **
>
>
> Any time I add or remove an item from a Spark list, the list resets itself
> to display the first element at the top. Is there a way to get the list to
> remember its current location? For example if I'm scrolled half way down a
> list and remove an item I would like the list to remain scrolled to where it
> was, rather than resetting.
>
> I'm currently listening for change events on the dataprovider and capturing
> the list layout's lastIndexInView, then using ensureIndexIsVisible to
> restore that index after the next display update. However, this still
> results in the list jumping around quite a bit. Is there a better solution?
> Shouldn't the list handle this by default?
>
>  
>

Reply via email to