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 ==
Not tested, but something like this should be close...
public function findFolderFromPath( folder : FolderClass,
fullPath:String ) : FolderClass {
if( folder.path == fullPath ) {
return folder;
} else {
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 =
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 =
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
5 matches
Mail list logo