voce está utilizando o método sincrono. Em uma linguagem com suporte a threads voce poderia criar uma thread extra para ler o arquivo enquanto mostrar o progresso na thread principal. lembra que o flash não tem suporte a threads. flash nao suporta threads, mas no Air a api de files do Air tem umas metodos especificos para trabalhar de forma assincrona.
de uma olhada nesse capitulo da documentação do air 1.5 e veja se voce encontra o que voce precisa. chapter 17 topic - Asynchronous programming and the events generated by a FileStream object opened asynchronously http://help.adobe.com/en_US/AIR/1.5/devappsflex/devappsflex.pdf abs Arian Pasquali SCJP, ACE Flex 3 with AIR http://arianpasquali.wordpress.com/ http://twitter.com/arianpasquali 2009/6/5 Thief <[email protected]> > Olá pessoal, > estava fazendo uns testes com o AIR para um trabalho da faculdade, ai criei > um protótipo só para simular o problema. > Ao ler os arquivos, queria que mostrasse o progresso. > Mas ao começar a ler os diretórios recursivamente, ele trava a aplicação e > só destrava quando acaba de ler. > Alguém tem alguma sugestão? > > Segue um snippet. > > Att, > > <?xml version="1.0" encoding="utf-8"?> > <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical" > backgroundColor="white"> > <mx:Script> > <![CDATA[ > import mx.effects.Pause; > import mx.utils.ObjectUtil; > [Bindable] private var isSearching:Boolean = false; > [Bindable] private var currentFile:String = ""; > private function searchDir(event:MouseEvent):void { > var file:File = new File(); > file.addEventListener(Event.SELECT, dirSelected); > file.browseForDirectory("Select a directory"); > function dirSelected(e:Event):void { > trace(file.nativePath); > isSearching = !isSearching; > getFilesInformation(file.nativePath); > currentFile = ""; > isSearching = !isSearching; > } > } > private function getFilesInformation(root:String):void { > var arq:File = new File(root); > var list:Array = arq.getDirectoryListing(); > for (var i:int = 0; i < list.length; i++){ > var file:File = new File(list[i].nativePath); > trace(file.nativePath); > if (file.isDirectory){ > getFilesInformation(file.nativePath); > trace("is dir"); > } else { > currentFile = file.nativePath; > trace(file.name + " size: " + file.size); > } > } > } > ]]> > </mx:Script> > <mx:Button click="searchDir(event)" label="Choose Dir" /> > <mx:Label text="{currentFile}" /> > <mx:ProgressBar indeterminate="true" visible="{isSearching}"/> > </mx:WindowedApplication> > > > > > --~--~---------~--~----~------------~-------~--~----~ Você recebeu esta mensagem porque está inscrito na lista "flexdev" Para enviar uma mensagem, envie um e-mail para [email protected] Para sair da lista, envie um email em branco para [email protected] Mais opções estão disponíveis em http://groups.google.com/group/flexdev -~----------~----~----~----~------~----~------~--~---
