views:

250

answers:

1

I'm trying to find a way to write to a text file from as2. I don't want to use any php or asp because my app needs to run without an internet connection. As3 has FileReference.save() and judging by the amount of searching I've done, as2 doesn't have that simple of a solution. Does anyone have a way even if its hacky to write to a txt file from as2?

+1  A: 

Unfortunately, there are only limited options for writing to a local disk from AS2:

  • You can store data locally using the SharedObject class, but this has a limited size (basically it's a cookie), and could be disabled by user preferences.

  • If you are running a local web service, you could conceivably use LoadVars() with PHP, but that's very hack-y and you'd be limited as to where your PHP script could write files to. Ditto for running other local server services such as ColdFusion...

  • You could make a flash-based desktop app using something like Zinc or mProjector - I've not used either of these, but I'm guessing they have some support for local file I/O. They're not free though (c. $400?). (EDIT: other alternatives are discussed here, especially HippoHX)

  • (EDIT) If you're using OSX and are happy for a 'manual' (rather than automated) option, you could use PrintJob() and "Save as PDF..." to output a PDF file, but obviously that's 'human-readable text', not really a 'text file' as such (OK, so it's a bit of a stretch, but I thought I should include this for completeness :).

That's all I can think of - perhaps there are other solutions? I'd be interested to know.

Hope this helps.

Richard Inglis
You can also write javascript to use HTML5 local storage or Google Gears, though that it still not a text file, it should give you enough storage if you are not happy with Cookies, which are the only persistent options if you are 100% Flash player in browser.
jarrett
@jarret, the SharedObject that Richard mentions is a kind of local storage for serialized object data, by default 100 K, but can be larger if the user allows it. It has been around since Flash Player 6, in 2002, and was used for local storage by some JavaScript libraries, before Google Gears and HTML5 local storage was around.
Lars