Save file locally with flash

I’m going to start with saying i’m a flash noob. I did some basic flash animation in high school but i’ve never tried to use it in a web environment.

My goal:
Embed XML in a webpage (hidden) on page load. User clicks a button and is able to download a file.xml containing the hidden xml. The only way I can think to do this is with flash because it is impossible with javascript.

I found this tutorial:
Save a file locally with Flash Player 10

However, I don’t know enough about flash to understand how to practically embed this code in an html document.

I’d appreciate any help or suggestions you may be able to offer.

You need either flash builder or flash cs5 then use that code to create a swf file. The code isn’t embedded in the html as such. The created swf file can then be embedded in your html page.

Alternatively, you can do this on the server side - send the xml data to the server either via a form or ajax, then have a script format it into the file and send back the correct headers to prompt a download.

This is how my system works.

XSLT is used to generate an html document. At this point I would need to generate the flash / embed the xml for download into the flash/html. So if the only way I can add the XML for download is thorugh an editor than this is going to work for me.

I also can’t use ajax b/c a requirement of the html document is it work with or without internet access if used locally on someones desktop.

Is what I’m asking outside of the realm of possibility with flash?

Yes, you can build a swf that will communicate with the embedding page via javascript. The javascript gathers whatever data it needs via the dom, and connects to the swf via externalInterface. The swf receives the data and formats it into an xml file then prompts the save to desktop.