6

I am trying to write a local file with Flash Player 10+ using the FileReference class, following the format from this blog post by Mike Chambers: http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/

Essentially the code is this:

private function onSaveButtonClick(event:MouseEvent):void{      
    fr = new FileReference();
    fr.save(fileToSave);}

It works fine locally on my machine but when used online, it doesn't bring up the save file dialogue when the save button is clicked. I assume this is some sort of permissions or security related issue?

Steven
  • 1,949
  • 2
  • 17
  • 30
  • Do you have an example running on a server? There's nothing that I know of that restricts FileReference.save when executing from a server, so a running example would be helpful. – JimmiTh Feb 07 '12 at 19:12
  • It works when I run it on a localhost server but not on my online server – Steven Feb 08 '12 at 06:40
  • What is `fileToSave`? Do `onFileSave`, `onCancel` or `onSaveError` trace anything – Eugeny89 Feb 09 '12 at 13:03
  • @Eugeny89 I debugged it more and it looks like its actually a crossdomain flash security issue related to getting an image from S3 to create a bitmap out of. I've created a new question at http://stackoverflow.com/questions/9217973/flash-flex-crossdomain-issue-using-bitmapdata-draw-for-image-from-aws-s3-res – Steven Feb 09 '12 at 20:11

2 Answers2

1

You should check your log for SecurityErrors. A sandbox violation is nearly always the cause when IO works locally but not online.

Peter Hall
  • 53,120
  • 14
  • 139
  • 204
0

Your instance of FileReference might be garbage collected. Same happens with file upload.

Try to move it to instance variable:

private var fr = new FileReference();
private function onSaveButtonClick(event:MouseEvent):void{      

    fr.save(fileToSave);
}
Stan Reshetnyk
  • 1,986
  • 1
  • 13
  • 31