[flexcoders] recursion help?

2010-06-23 Thread Baz
I'm having a heck of a time converting this search of nested arrays from fixed depth to variable depth using recursion. Any recursion gurus willing to help? public function filterFolderFromPath(fullPath:String):void { for each (var currentFolder:Folder in folders) { if(currentFolder.path ==

RE: [flexcoders] recursion help?

2010-06-23 Thread Gregor Kiddie
Not tested, but something like this should be close... public function findFolderFromPath( folder : FolderClass, fullPath:String ) : FolderClass { if( folder.path == fullPath ) { return folder; } else {

Re: [flexcoders] recursion help?

2010-06-23 Thread Oleg Sivokon
public function filterFolderFromPath(fullPath:String, children:Vector.Folder):Folder { var foundChild:Folder; for each (var currentFolder:Folder in children) { if (currentFolder.path === fullPath) return currentFolder; else if (currentFolder.children.length) { foundChild =

Re: [flexcoders] recursion help?

2010-06-23 Thread Oleg Sivokon
Actually, just for kicks: public function filterFolderFromPath(fullPath:String, children:Vector.Folder):Folder { for each (var currentFolder:Folder in children) { if (currentFolder.path === fullPath) return currentFolder; else if (currentFolder.children.length) { currentFolder =

Re: [flexcoders] recursion help?

2010-06-23 Thread Baz
Awesome! Gregor it works perfectly, not even a slight adjustment needed, thanks! So much prettier now :) Oleg, thank you too for your input! Cheers, Baz