The lack of information about how to populate the Tree component with
a non-XML data source is driving me nuts.

Now I'm having an issue with populating multiple Trees, as soon as I
set the dataProvider for the second Tree the information in both gets
corrupted. I'm about ready to write this off as a bug and convert the
object I pulled with AMF to XML just to comply with what seems
standard.

If anyone can see something wrong with this method for recursing an
Object to make it Tree component complaint please straighten me out.

//---------------------------------------------------//

private function makeTreeObject(obj:Object, label:String=null):Object
{       
        obj['label'] = label;
        var children:Array = new Array();
        
        for (var i in obj){
                if (i == 'length' || i == 'label') continue;
                
                if (typeof obj[i] == 'object'){
                        children.push(makeTreeObject(obj[i], i));       
                } else {
                        if (typeof i == 'number'){
                                children.push({label:obj[i]});
                        } else {
                                children.push({label:i+":"+obj[i]});
                        }
                }
                if (label!=null) delete obj[i];
        }       
        if (label!=null) obj['children'] = children;
        
        return obj;
}

Reply via email to