views:

42

answers:

1

i'm newbie, so please help me...

package com.func {
    public class Downloader {
        import flash.net.FileReference;
        import flash.net.URLRequest;

        private var req:URLRequest = new URLRequest();
        private var fr:FileReference = new FileReference();
        public function Downloader(){
        }

        public function download():void{
            req.url = "http://www.yourdomain.com/example.txt";
            fr.download(req);
        }
    }
}

I have a fw questions: 1. how to save downloaded file automatically in file system directory (ex: applicationDirectory as default), without open browse dialog to save the file. 2. how to open that files after download complete into a textarea without save the file to filesystem first.... thaks....

A: 

Data from a url can be downloaded using a URLLoader. You can get a String from this in the complete event handler.

The string can then be set as the text property of the TextArea.

You can write to a file, without user interaction, using Air's FileStream class. The same class can also be used to read the file.

fgb
anyone can help me with code ??leave the sample code here.....
rie
Which part are you having trouble with? Sample code for URLLoader is in the linked docs. For filesteam, see: http://www.insideria.com/2008/03/beginning-air-accessing-the-fi-1.html
fgb
actually no.1 : save downloaded file automatically in file system (directory have been determined, ex:applicationDirectory), without open browse dialog to save the file.thanks alot
rie