title: download multiple files flash
body: <p>i have a Flash application with a datagrid filled with filenames and i want the user to be able to check multiple files from that grid and download them to his local drive. The files are stored in a blob field in a database and im using php ro retrieve them. Im trying to use URLLoader and FileReference to download the files, but it is not working.
  Here's the code:</p>
  
  <pre><code>private function downloadSelected():void {
              var dp:Object=dg.dataProvider;
              var cursor:IViewCursor=dp.createCursor();
  
              while( !cursor.afterLast )
              {
  
                  //Alert.show(cursor.current.IsChecked.toString());
                  if (cursor.current.IsChecked.toString()=="true") {
                      //myAmostras.push(cursor.current.CodBarras.toString());
                      //nenhumaAmostra=false; 
  
                  var u:URLRequest= new URLRequest;
                      var variables:URLVariables = new URLVariables();            
                      variables.amostras = cursor.current.CodBarras.toString();
                      variables.disposition="attach";
                      u = new URLRequest("savereports.php");
                      u.method = URLRequestMethod.POST;
                      u.data=variables;
  
  
                      pdfloader = new URLLoader();
                      //pdfloader.dataFormat=URLLoaderDataFormat.BINARY;
                      pdfloader.addEventListener(Event.COMPLETE, completeHandler,false,0,true);
                      pdfloader.addEventListener(IOErrorEvent.IO_ERROR, downloadError); 
  
  
                      try {
                          pdfloader.load(u);
                      } catch (error:Error) {
                          Alert.show("Unable to load requested document.");
                      }
  
                  }
                  cursor.moveNext();
              }   
          }
  
          private function downloadError(event:Event):void {
              Alert.show("Error loading file");
          }
  
  
  
          private function completeHandler(event:Event):void {
  
              var myFileReference:FileReference = new FileReference();
  
              myFileReference.save(event.target.data);
  
          }
  </code></pre>
  
  <p>Can anyone help me on this?</p>