Is there a way to get a s:List to display it's items in reverse order? Not having to make a copy of the dataProvider would be ideal. Thanks.
A:
The s:List control does not have the option to show items in reverse order. All is controlled by manipulating the dataProvider or the "source" of the dataProvide.
Here is how you could achieve this
public function showReverseList(data:Array):void
{
var reverseList:Array;
var i,count = data.length;
for(i = count-1 ; i >= 0 ; i--)
{
// add items in reverse order
reverseList.push(data[i]);
}
myListControl.dataProvider = reverseList;
}
Adrian Pirvulescu
2010-08-12 19:26:58
Thanks for the suggestion, this is what's already in place. I'm just wondering if there's a better way to do it. I find it hard to believe that there's nothing built-in to achieve that.
sharvey
2010-08-12 19:39:08
trust me... there is nothing like that inside the list. and if there would be one, it would like like the code you already have.
Adrian Pirvulescu
2010-08-12 19:59:36
The layout of the dataGroup inside the list could logically handle it.
sharvey
2010-08-12 20:07:34
Sorting the collection as Wade Mueller suggests is the most flexible way of achieving this, especially if you need to change the sort order later. Otherwise you can also use the `Array.reverse()` function to reverse the array in-place.
Sly_cardinal
2010-08-12 22:56:55
+1
A:
You can set a Sort on your dataProvider (assuming it implements ICollectionView, like an ArrayCollection for example) and call the Sort.reverse() method. Hope that helps.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/Sort.html
Wade Mueller
2010-08-12 21:52:52