private var fileStream:FileStream;
private function downloadFile():void
{
var file:File=File.desktopDirectory.resolvePath('fileName');
fileStream=new FileStream();
fileStream.open(file, FileMode.WRITE);
var urlLoader:URLLoader=new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onDownloadedComplete);
urlLoader.dataFormat=URLLoaderDataFormat.BINARY;
urlLoader.load(new URLRequest('downloadLink'));
}
private function onDownloadComplete(evt:Event):void
{
fileStream.writeBytes((evt.target).data);
fileStream.close();
}