Of course, if anyone has a better solution, just post a comment at the end of this post!
Here it goes.
1. First we need to extend the BaseScrollViewportStrategy class. This could look something like this:
package se.marteinn.app.controls.viewport.context
{
import com.custardbelly.as3flobile.controls.viewport.context.BaseScrollViewportStrategy;
import com.custardbelly.as3flobile.controls.viewport.context.IScrollViewportStrategy;
import flash.geom.Point;
public class CustomScrollViewportStrategy extends BaseScrollViewportStrategy implements IScrollViewportStrategy
{
public function moveToStaticPoint( point:Point ):void
{
_currentScrollPositionX = point.x;
_currentScrollPositionY = point.y;
_coordinate.x = _currentScrollPositionX;
_coordinate.y = _currentScrollPositionY;
}
}
}
2. Then we need to extend ScrollList and add this method: moveToStaticPoint and then override getDefaultScrollContext.
// This method sets a new scrolling position on both the ScollList itself and the strategy instance.
public function moveToStaticPoint ( point:Point ) : void
{
var strategy:CustomScrollViewportStrategy;
strategy = _scrollContext.strategy as CustomScrollViewportStrategy;
_currentScrollPosition = point;
strategy.moveToStaticPoint( point );
_listHolder.x = point.x;
_listHolder.y = point.y;
}
// And this method makes sure that we implement the new strategy element.
override protected function getDefaultScrollContext():IScrollViewportContext
{
return new ScrollViewportMouseContext( new CustomScrollViewportStrategy() );
}
3. After that. You can use ScrollList like this.
var scrollList:MyScrollList; // Dump the scrollPosition (clone() is important). We will use this position after the dataProvider has changed position = scrollList.scrollPosition.clone(); // Do your stuff. for instance alter the dataProvider of the scroll list // scrollList.dataProvider = updatedContent; // Finish it off by running the moveToStaticPoint method. The ScrollList will now be set at the same position as where we started. scrollList.moveToStaticPoint( position );