<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="FileReference_download_test_2"
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:net="flash.net.*"
layout="vertical"
verticalAlign="middle"
backgroundColor="white" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private const DOWNLOAD_URL:String = "http://blog.flexexamples.com/wp-content/uploads/FileReference_download_test_2/bin/srcview/FileReference_download_test_2.zip";
private function btn_click(evt:MouseEvent):void {
var urlReq:URLRequest = new URLRequest(DOWNLOAD_URL);
fileReference.download(urlReq);
}
private function onEvent(evt:Event):void {
Alert.show(evt.toString(), evt.type);
}
]]>
</mx:Script>
<net:FileReference id="fileReference"
complete="onEvent(event);"
cancel="onEvent(event);"
httpStatus="onEvent(event);"
ioError="onEvent(event);" />
<mx:Button id="btn"
label="Download source"
click="btn_click(event);" />
</mx:Application>