Show Me More: Paging Array Collections
I have been working for a while recently on grooveshark’s newest feature: activity I needed to come up with a way for our array collections to only render or show a small set of what feeds actually have in them. [People stop listening to so much damn music.]
What is great about array collections is they handle all sorts of stuff for you, such as binding and updates. But what’s really great is the ability to differentiate a view from the underlying data, which allows you the use of filters for features like active searching on a collection.
So what I needed was a way to click show more and it would reveal the next set.
And extend and implement…
private var _pagesVisible:uint = 1;
[ChangeEvent("collectionChange")]
public function get pagesVisible():uint
{
return _pagesVisible;
}
public function set pagesVisible(value:uint):void
{
// allow it to be ready for soon to be populated data
if (value <= (pages+1)) {
_pagesVisible = value;
this.refresh();
}
}
private function feedFilter(item:Object):Boolean
{
var isIncluded:Boolean
= (source.indexOf(item) < PAGE_SIZE * pagesVisible);
hasMorePages = !isIncluded;
return (isIncluded);
}