Monthly Archives: January, 2011

Finding the maximum scroll position of a Spark List

Recently, we had a very important person (at least in my opinion), leave our QA team. Peter deHaan, author of Flex Examples left Adobe for bigger and brighter things. If you are new or old to Flex, you have at some point found yourself on Peter’s Flex Examples blog. Since he has moved on, you’ll probably hear nothing but crickets coming from Flex Examples. (Peter, correct me if I’m wrong!)

So, some of us on the team were thinking that we needed to get our butts in gear and begin blogging on a more frequent basis to fill the void. I’m starting with this very simple example of ‘finding the maximum scroll position of a Spark List’. This is helpful whenever you want to scroll down to the end of a List in your application. I recently had this need when I was building a mobile app.

To find the max scroll position, you should subtract the height or width of the DataGroup from the contentHeight or contentWidth of the DataGroup.

maxVerticalScrollPosition = myList.dataGroup.contentHeight – myList.dataGroup.height;

Here are examples:

Source: MaxScrollPositions.mxml

SWF: MaxScrollPositions.swf