nm..im a dummy! got it

On Fri, Dec 19, 2008 at 3:06 PM, Dan Vega <[email protected]> wrote:

> I think I am finally getting some where. In case you don't know what I have
> been up to I will bring you up to speed. I am building a file explorer where
> the left side will only be directories. When you select a directory the
> contents (files) will show up in a datagrid on the right. I was having some
> issue with display branches but I solved that by inserting an empty array on
> any folder i knew had children.
>
> Now I am trying to append the directories when the user starts drilling
> down. So first I have an onItemOpen() method for when the folder is opened.
> All this does is figure out the path and call my server side function that
> will retrieve me a list of directories for a given path.
>
>             private function onItemOpen(event:TreeEvent):void {
>                 var path:String = event.item.path;
>                 FileManager.getDirectories(path);
>             }
>
> I have a onResult method for the getDirectories() method called
> listDirectories(). What I am doing here is
>
> 1. getting the list of directories.
> 2. if the tree data provider (_directorheies) is null we know this is the
> base.
> 3. if not I am trying to figure out a way to append this array (or swap
> out) with the children empty array i have as a placeholder.
>
> Is this the right approach? I am obviously doing something wrong, hope
> someone can point that out!
>
>             private function listDirectories(event:ResultEvent):void {
>                 var dirs:Array = event.result as Array;
>                 var parent:String = dirs[0].parent;
>                 var pos:uint = -1;
>
>                 // if the _directories array is null this is our root
> request
>                 if(_directories == null) {
>                     _directories = dirs;
>                 }else {
>                     // we know the parent of the item that was clicked,
> find the array position
>                     for(var i in _directories){
>                         if(_directories[i].path == parent){
>                             pos = i;
>                             break;
>                         }
>                     }
>                     //if we found the position append the directories to
> the children node
>                     _directories[i].children = dirs;
>                     trace(ObjectUtil.toString(_directories));
>                 }
>             }
>
>
>
>

Reply via email to