Categories
Actionscript Flash

Save XML and text files from Flash to your HD with AS3 and PHP

In this post I’ll show how to save a file from AS3 to your local HD. In another post I’ve explained how to load a file from HD to Flash.

For a project I’ve been looking around for a decent solution to the problem of saving a text file (to be more precise XML file) from Actionscript 3 to my local harddisc but i couldn’t find a solution for this (what not necessarily means that there is none).

Saving and loading can be smoothly achieved with Adobe Air but not with Flash because Flash has been designed to run on the web. However, it is possible to download and upload files via AS3 on and from your HD to and from a webserver. Think of an Flash MP3 shop: You can click on an MP3 in Flash and you will be asked where to save the file and afterwards the file is being downloaded to the chosen location on your HD. So it must be somehow possible.

Additionally, it is possible to create XML or other text in Flash and store it on a webserver and vice versa.

Thus I came upon following solution:

Howto save and load text files with AS3
Figure 1: Howto save and load text files with AS3