Sunday, February 27, 2011

Flash Error #3000: Illegal path name

This Flash action script error 3000 with message "Illegal path name" happens when you try to access a wrong path.


Solution:

private var file:File = File.documentsDirectory; 
public function download():void{
  var pdfFilter:FileFilter = new FileFilter("PDF Files", "*.pdf"); 
  file.browseForOpen("Open", [pdfFilter]); 
  file.addEventListener(Event.SELECT, fileSelected); 
}
    
private function fileSelected(e:Event):void { 
  var destination:File = File.applicationDirectory
  destination = destination.resolvePath("test.pdf");
  
  /*
  //This works, also if the file to copy is placed inside the appfolder
  file.copyTo(destination, true);
  */

  /**
   * This Throws me an Error #3000, but ONLY if the file is located in
   * the App folder
   */
  file.openWithDefaultApplication();
}

No comments:

Post a Comment