3 Replies Latest reply on Sep 19, 2009 4:41 PM by Chris Deely

    Help (please) FileSystemDataGrid & FileSystemTree very slow on network drive

    xfer_rdy
      Hi,
      I'm new to air and flex, so excuse me if this is a silly question.

      I'm writing a vista style file manager using as FileSystemDataGrid & FileSystemTree my first project. Straight forward stuff. When I access a local drive, the controls react in a 1 second, slow but tolerable. However, if I access a network or a USB drive, the controls take between 15 and 30 seconds to respond. Vista complains the app is unresponsive. Am I doing something wrong ? Is there a way to preload the file directories ?

      cheers
      -g
        • 2. Re: Help (please) FileSystemDataGrid & FileSystemTree very slow on network drive
          xfer_rdy Level 1
          Here you go, some of the cursor stuff isn't in.
          If you have a network drive open, its very slow. If the File grid has a lot of file "50" you can barely expand the app window.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:hc="hc.*"
          applicationComplete="init();"
          mouseOver="mouseEnterHandler(event);" mouseOut="mouseExitHandler(event);">

          <mx:Script>
          <![CDATA[
          public var mouseStateBusy:Boolean =false;
          public var mouseStateBusyOnExit:Boolean =false;

          import mx.events.FileEvent;
          import mx.controls.FileSystemDataGrid;
          import mx.managers.CursorManager;

          private function mouseExitHandler(evt:Event):void {
          if(mouseStateBusy==true){
          mouseStateBusyOnExit=true;
          CursorManager.removeBusyCursor();
          }
          }
          private function mouseEnterHandler(evt:Event):void {
          if(mouseStateBusyOnExit==true){
          if(mouseStateBusy==true){
          CursorManager.setBusyCursor();
          }
          }
          }

          private function btn_click(evt:Event):void {
          var f:File = File.desktopDirectory;
          FileTree.openSubdirectory(f.nativePath);
          FileTree.validateNow();
          FileTree.selectedPath =f.nativePath;
          FileDetails.navigateTo(f);
          }

          private function grid_dbl_click(evt:FileEvent):void {
          FileTree.openSubdirectory(evt.file.nativePath);
          FileTree.validateNow();
          var idx:int = FileTree.findIndex(evt.file.nativePath);
          FileTree.scrollToIndex(idx);
          }
          private function btn_up_click(evt:MouseEvent):void {
          FileDetails.navigateUp();
          }

          private function dataGrid_directoryChange(evt:FileEvent):void {
          application.status = evt.file.nativePath;
          }
          ]]>
          </mx:Script>

          <mx:VBox x="0" y="62" width="100%" height="100%" borderStyle="outset">
          <mx:ApplicationControlBar dock="true" width="100%" cornerRadius="0">
          <mx:Button id="btn"
          label="Open desktop directory"
          click="btn_click(event);" />
          <mx:Button label="t" click="mouseStateBusy=true; CursorManager.setBusyCursor();"
          enabled="true"/>
          <mx:Button label="Up" click="FileDetails.navigateUp();"
          enabled="{FileDetails.canNavigateUp}"/>
          <mx:TextInput text="Text" width="337" height="20" id="FilePath" enabled="true" borderStyle="inset" cornerRadius="0" textAlign="left" editable="true"/>
          <mx:FileSystemHistoryButton
          label="Back"
          dataProvider="{FileDetails.backHistory}"
          enabled="{FileDetails.canNavigateBack}"
          click="FileDetails.navigateBack();"
          itemClick="FileDetails.navigateBack(event.index)"/>
          <mx:FileSystemHistoryButton label="Forward"
          dataProvider="{FileDetails.forwardHistory}"
          enabled="{FileDetails.canNavigateForward}"
          click="FileDetails.navigateForward();"
          itemClick="FileDetails.navigateForward(event.index)"/>
          </mx:ApplicationControlBar>
          <mx:HDividedBox width="100%" height="100%">
          <mx:FileSystemTree height="100%" enabled="true" showIcons="true" showHidden="false" showExtensions="false" id="FileTree" width="25%"
          change=" mouseStateBusy=true;
          var path:String = FileDetails.directory.nativePath;
          if(path != File(FileTree.selectedItem).nativePath){
          FileDetails.navigateTo(File(FileTree.selectedItem));
          }"
          enumerationMode="directoriesOnly"
          borderStyle="inset"
          useHandCursor="true"
          />

          <mx:FileSystemDataGrid width="100%" height="100%" id="FileDetails"
          showHidden="TRUE"
          directoryChanging="
          mouseStateBusy=true;
          CursorManager.setBusyCursor();"
          directoryChange="
          FilePath.text=event.file.nativePath;
          if(FileTree.selectedPath != event.file.nativePath){
          FileTree.openSubdirectory(event.file.nativePath);
          FileTree.selectedPath =event.file.nativePath;
          }
          mouseStateBusy=false;
          CursorManager.removeBusyCursor();"
          borderStyle="inset" enabled="true" showIcons="true" showExtensions="true"/>
          </mx:HDividedBox>
          </mx:VBox>

          </mx:WindowedApplication>
          • 3. Re: Help (please) FileSystemDataGrid &amp; FileSystemTree very slow on network drive
            Chris Deely

            I have written an article on how I managed to speed up the FileSystemTree: http://blog.webdeely.com/2009/07/fixing-the-filesystemtree/

             

            The short answer is that the internal classes apply filtering and sorting after reading the data from the disk.  With large directories or slow network connections, this can add a lot of processing time.  My post includes an extended version of the class that circumvents the processing.  It is not perfect, but allows for faster listing of directory contents.

             

            Hope it helps!