• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 630
  • Last Modified:

Sort Flex FileSystemList

How can i sort the files listed in an Adobe Flex FileSystemList object?

I am sssuming it is easy, but i am new to flex and can't seem to figure out.
0
trademark16
Asked:
trademark16
  • 3
  • 2
1 Solution
 
heppaCommented:
how would you want them to be sorted?

you could write a callback function and use that function in the nameCompareFunction attribute.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/FileSystemList.html#nameCompareFunction
0
 
trademark16Author Commented:
Just by name is fine.  Currently they do not come in that way and i want to guarantee it does.
0
 
heppaCommented:
normally they should... could you post your mxml please?

an example for reverse sorting would be:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
      <![CDATA[
            public function compareFileNames(name1:String, name2:String):int{
                  if(name1 > name2)return -1;
                  else if (name2 > name1) return 1;
                  else return 0;
            }
      ]]>
</mx:Script>
    <mx:Button label="Up" click="fileList.navigateUp();"
        enabled="{fileList.canNavigateUp}"/>
    <mx:FileSystemList id="fileList" nameCompareFunction="compareFileNames"/>
</mx:WindowedApplication>
0
 
trademark16Author Commented:
I altered your sample a bit to be not reverse soriting and it seems to work now, thanks.
0
 
heppaCommented:
It was a pleasure! ;)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now