This content has been marked as final. Show 2 replies
I have done something similiar. I basically hooked up directory.getDirectoryListingAsync() and callLater. You could use Alex Harui's PseudoThread ( http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html) for a much cleaner way.
The performance was decent and most importantly, the UI did not lock up. There should be only one outstanding call to getDirectoryListingAsync at a time. When the listing event fires, iterate through the list and when you encounter a folder, save an index to the position in the result and call a callLater to a function that does getDirectoryListingAsync on that folder. When that completes, go back to the saved index and do the same for subsequent folders.
Thanks for your advice.
I ended up doing a weird recursion that gave me speed and no lockup. The way it works is that I get the directory listing and loop through it in a while/shift loop pushing files into a tmp file. When I hit a directory I stop the while loop and call setTimeout to run this method for the subdirectory on and on in a recursive pattern. Then I jump back to the parent directory while loop and take off where I left off.
This is a bit screwy but it works well for the fact I get the speed of the while loop but enough pause in the thread with setTimeout to refresh windows. I looked into the getDirectoryListingAsync but I really wanted to read things in a tree order and Async couldn't guarantee they would be written into the tmp file in a tree order, plus my method guarantees only one thing writing to the tmp file at a time.