amigao, obrigado pela resposta, mas infelizmente nao me ajudou muito, eu
tentei e nada



<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009";
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here
-->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[


            import flash.events.IOErrorEvent;
            import flash.events.ProgressEvent;
            import flash.filesystem.*;
            import flash.net.URLRequest;
            import flash.net.URLStream;
            import flash.utils.ByteArray;

            import mx.controls.Alert;

            private var urlStream:URLStream;


            private function baixaArquivo():void{

                var request:URLRequest;

                urlStream = new URLStream();
                request = new URLRequest("
http://download.mozilla.org/?os=win&lang=pt-BR&product=firefox-4.0.1"; );

                urlStream.addEventListener( ProgressEvent.PROGRESS,
downloadProgresso );
                urlStream.addEventListener( Event.COMPLETE, downloadCompleto
);
                urlStream.addEventListener( IOErrorEvent.IO_ERROR,
downloadErro );

                urlStream.load( request );

            }

            private function downloadProgresso(event:ProgressEvent):void{
                //var percent:uint = event.bytesLoaded / event.bytesTotal *
100;
                pg.setProgress(event.bytesLoaded,event.bytesTotal);
                //trace('Bytes Baixados: ' + event.bytesLoaded + ' de ' +
event.bytesTotal + ' - ' + percent + '%');

            }

            private function downloadErro(event:IOErrorEvent):void{

                // Erro no download da mídia... adiciona ocorrência no log.
                Alert.show(event.toString());
            }

            private function downloadCompleto(event:Event):void{
                var byteArray:ByteArray = new ByteArray();
                var arquivoStream:FileStream;
                var file:File;

                event.target.readBytes(byteArray);

                // para gravar dentro da pasta da aplicação
                //file = new File( File.applicationDirectory.resolvePath(
'arquivo.extensao' ).nativePath );
                // Para gravar dentro de uma pasta interna da aplicação
                //file = new File( File.applicationDirectory.resolvePath(
'pasta/arquivo.extensao' ).nativePath );

                // Para gravar no desktop
                file = new File( File.desktopDirectory.resolvePath(
'firefox.exe' ).nativePath );

                // Para gravar na pasta de documentos
                //file = new File( File.documentsDirectory.resolvePath(
'arquivo.extensao' ).nativePath );

                arquivoStream = new FileStream();
                arquivoStream.open(file, FileMode.WRITE);
                arquivoStream.writeBytes(byteArray);
                arquivoStream.close();
                urlStream.close();

            }
        ]]>
    </fx:Script>
    <s:Button x="360" y="149" label="Button" id="btn"
click="baixaArquivo()"/>
    <mx:ProgressBar x="301" y="232" id="pg"/>
    <s:TextInput x="301" y="86" id="link"/>
</s:WindowedApplication>


Em 6 de maio de 2011 14:15, Wemerson Couto Guimarães
<wemerso...@gmail.com>escreveu:

> Tá aqui parceiro... Fiz um negócio bem grosso-modo... usando URLStream....
> que é mais interessante porque baixa a app byte a byte... então não pesa
> tanto...
>
>
>
> import flash.events.IOErrorEvent;
> import flash.events.ProgressEvent;
> import flash.filesystem.*;
> import flash.net.URLRequest;
> import flash.net.URLStream;
> import flash.utils.ByteArray;
>
> var urlStream:URLStream;
>
> private function baixaArquivo():void{
>
>     var request:URLRequest;
>
>     urlStream = new URLStream();
>     request = new URLRequest( 'www.seudominio.com.br/arquivo.extensao' );
>
>     urlStream.addEventListener( ProgressEvent.PROGRESS, downloadProgresso
> );
>     urlStream.addEventListener( Event.COMPLETE, downloadCompleto );
>     urlStream.addEventListener( IOErrorEvent.IO_ERROR, downloadErro );
>
>     urlStream.load( request );
>
> }
>
> private function downloadProgresso(event:ProgressEvent):void{
>     var percent:uint = event.bytesLoaded / event.bytesTotal * 100;
>
>     trace('Bytes Baixados: ' + event.bytesLoaded + ' de ' +
> event.bytesTotal + ' - ' + percent + '%');
>
> }
>
> private function downloadErro(event:IOErrorEvent):void{
>
>     // Erro no download da mídia... adiciona ocorrência no log.
>     logErros( );
> }
>
> private function downloadCompleto(event:Event):void{
>     var byteArray = new ByteArray();
>     var arquivoStream:FileStream;
>     var file:File;
>
>     event.target.readBytes(byteArray);
>
>
>     // para gravar dentro da pasta da aplicação
>     file = new File( File.applicationDirectory.resolvePath(
> 'arquivo.extensao' ).nativePath );
>     // Para gravar dentro de uma pasta interna da aplicação
>     file = new File( File.applicationDirectory.resolvePath(
> 'pasta/arquivo.extensao' ).nativePath );
>
>     // Para gravar no desktop
>     //file = new File( File.desktopDirectory.resolvePath(
> 'arquivo.extensao' ).nativePath );
>
>     // Para gravar na pasta de documentos
>     //file = new File( File.documentsDirectory.resolvePath(
> 'arquivo.extensao' ).nativePath );
>
>     arquivoStream = new FileStream();
>     arquivoStream.open(file, FileMode.WRITE);
>     arquivoStream.writeBytes(byteArray);
>     arquivoStream.close();
>     urlStream.close();
>
> }
>
>
>
> Abraço
>
>
> --
> *Wemerson Guimarães*
> Rio Verde - Go
>
>  --
> Você recebeu esta mensagem porque está inscrito na lista "flexdev"
> Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com
> Para sair da lista, envie um email em branco para
> flexdev-unsubscr...@googlegroups.com
> Mais opções estão disponíveis em http://groups.google.com/group/flexdev

-- 
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com
Para sair da lista, envie um email em branco para 
flexdev-unsubscr...@googlegroups.com
Mais opções estão disponíveis em http://groups.google.com/group/flexdev

Responder a