Creating text file from as2
I'm trying to find a way to write to a text file from as2. I don't wa开发者_如何学JAVAnt 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?
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.
精彩评论