<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/25/saving-files-locally-using-the-filereference-classs-save-method-in-flash-player-10/ -->
<Application name="FileReference_save_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        xmlns:net="flash.net.*"
        layout="flex.layout.BasicLayout"
        creationComplete="init();" viewSourceURL="srcview/index.html">

    <Script>
        <![CDATA[
            private const xmlObj:XML = describeType(FileReference);

            private function init():void {
                textArea.text = xmlObj.toXMLString();
            }

            private function btn_click(evt:MouseEvent):void {
                fileReference.save(xmlObj, "describeType.xml");
            }
        ]]>
    </Script>

    <Declarations>
        <net:FileReference id="fileReference" />
    </Declarations>

    <mx:Panel id="panel"
            width="500"
            height="300"
            verticalCenter="0"
            horizontalCenter="0">
        <mx:TextArea id="textArea"
                editable="true"
                width="100%"
                height="100%" />
        <mx:ControlBar horizontalAlign="right">
            <Button id="btn"
                    label="Save"
                    click="btn_click(event);" />
        </mx:ControlBar>
    </mx:Panel>

</Application>