I need to downlo开发者_Python百科ad a file without using FileReference Object in Flex. In fact I don't want to show the Dialog Box while ask for download. I just want to download in my default location. How can do achieve this.
Thanks, Rejeev.
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();
}
精彩评论