A long time ago when I was first getting into AIR, I created a downloader application to do basically what you are asking help for. Below is code for the part that you need to download and save a file. If the file you are downloading is dynamically generated or has special reference links, you will have to do something fancy for knowing the file extension to know what the full file name should be. I just tested the code for downloading an image and the HTML file for the FileStream ASDoc
import flash.events.Event;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.utils.ByteArray;
var documentsDirectory:File = File.documentsDirectory;// active user documents directory
var fileName:String;
var fileToSave:File;
var fileStream:FileStream;
var fileData:ByteArray;
var urlRequest:URLRequest = new URLRequest("http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html");
var urlStream:URLStream = new URLStream();
urlStream.addEventListener(Event.COMPLETE, onDownloadComplete);
urlStream.load(urlRequest);
function onDownloadComplete(e:Event):void {
// get the index position of the last forward slash in the file path
var startIndex:int = urlRequest.url.lastIndexOf("/") + 1;
// set fileName equal to url string starting after the last forward slash
fileName = urlRequest.url.substring(startIndex);
// create a new File object at the user Directory folder with the correct file
fileToSave = documentsDirectory.resolvePath(fileName);name
// create ByteArray to store data downloaded from URLLoader
fileData = new ByteArray();
// write the data from URLLoader to ByteArray
urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
// create FileStream to save data to File
fileStream = new FileStream();
// open file in a WRITE mode to save data to the File
fileStream.open(fileToSave, FileMode.WRITE);
// write the data to the file
fileStream.writeBytes(fileData, 0, fileData.length);
// close FileStream when done
fileStream.close();
}