views:

467

answers:

3

Hi,

How do we save file locally in Flash (ActionScript 3) without displaying dialog.

I know we can use the following code to save file locally but it prompts Save dialog. I don't want this dialog while saving file locally.

var fs: FileReference = New FileReference(); fs.save(data,filename);

Please tell me the solution. Many Thanks in Advance.

+3  A: 

I don't think this is possible due to security constraints. Flash is simply not allowed to create files without the user knowing. (And there might be no obvious place to give the Flash application write access on the filesystem.)

kb
A: 

as kb said, this is not possible, and I'm actually glad. That would soooo dangerous but there ways of going around this, for example utilizing a java applet that has the saving delegated.

but consider that no user wants a file saved to their computer without them knowing from some website, this is how malicious stuff gets onto your computer.

Daniel
A: 

As kb and Daniel says, you can't save a file without user dialog.

But you can save smaller amounts of data in a SharedObject, by default up to 100K. SharedObjects can be regarded as a Flash counterpart to browser cookies, but it can store more data, and structured data since it supports serialization of objects. A typical usage case would be saving a high-score list for a game.

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/SharedObject.html

Lars