1 Reply Latest reply on Apr 29, 2010 7:35 PM by David_F57

    Air download files from server


      I have an Air app that should display a DataGrid with a list of files that can be downloaded from my web server. It works perfect as a Flex program. I get 2 errors that I list at the bottom. I have a downloadFile.as file in a com folder








      import mx.collections.ArrayCollection;


      import mx.rpc.events.ResultEvent;


      import mx.controls.Alert;


      import mx.events.ListEvent;






      Bindable] public var directoryDS:ArrayCollection;



      Bindable] public var serviceURL:String;



      Bindable] public var fileIndex:Number;



      public function initApp():void


      serviceURL =


      "http://www.youngsmarket.com/directory.cfm"; //Set the URL to the httpservice

      directoryDS =


      new ArrayCollection([]); // This is where the results of the httpservice will end up.

      fileIndex = -1;









      // Taking the data returned from the httpservice and creating FileDownload objects to populate the directoryDS array collection.



      private function setDataSource(evtObj:Object):void




      var fileDL:DownloadFile;


      var collection:ArrayCollection = evtObj.directory.file as ArrayCollection; // pass httpservice result into a local scope



      var i:int;



      //loop over results and create a new DownloadFile object and add it to the directoryDS ArrayCollection



      for (i=0;i < collection.length; i++)


      fileDL =

      new DownloadFile();

      fileDL._file = collection.getItemAt(i).name;

      fileDL._url =

      "http://www.youngsmarket.com/myFiles/"; // Change this to match your Files directory path.

      fileDL._size = collection.getItemAt(i).size;

















      id="directory_srv" url="{serviceURL}" result="setDataSource(event.result)"/>




      dataProvider="{directoryDS}" id="filesDG" doubleClickEnabled="true" itemDoubleClick="downloadFile()" change="setFileIndex(event.target.selectedIndex);"


      100%" height="100%" borderStyle="none" themeColor="#73B9B9">




      <mx:DataGridColumn dataField="_file" headerText="File" minWidth="150" />


      <mx:DataGridColumn dataField="_size" headerText="Size" minWidth="100" />






      Error on this line:   var fileDL:DownloadFile;

      the error is:   Type not found or is not compile time constant: DownloadFile


      the next error is this line:    fileDL = new DownloadFile();

      the error is:     call to a possibly undefined method DownloadFile