I've used the search app at the link below:
Is there anyway to stop it on command or with a push at a button?
The app is written so that it reads the directories asynchronously and (I believe) only processes one directory at a time, so there's a way to prevent further searching, and to give the illusion that the searching has stopped completely.
(Disclaimer: I haven't actually tested this, but I'm pretty sure it works.)
In the <mx:Script> block, create a variable, a Boolean, to track if the search operation has been cancelled:
private var _cancelled:Boolean = false;
Add a button or some UI element that makes the _cancelled variable true when the user wants to stop the search:
_cancelled = true;
Then at the start of the dirListed() method, add these lines:
That way, if the user has cancelled the operation then when whatever directory is currently being read has finished and calls the event handler, the method returns so that directory's children etc. don't ever get added to the list of directories to search. In addition, any directories that have already been added to the list of directories to check won't ever get checked, since the app only actually reads one directory at a time, and the dirListed() method returns so the getDirectoryListingAsync() method never gets called again.
Thanks it worked for me.