This took me a long time to figure out. It isn't the whole code (that I use) but I think it will work on it's own. Items between # are variables you need to name yourself.
Code:
function tree_pop() {
var xml_object:XML = new XML();
for (i=0; i< #NUMBER OF ITEMS TO ADD# ; i++) {
current = # REFERENCE POINT (can be number or whatever) #;
labels = # ITEM TO DISPLAY# ;
parent = # REFERENCE POINT TO ADD AS A CHILD OF #;
this[current + "_node"] = xml_object.createElement("node");
this[current + "_node"].attributes.label = labels;
this[current + "_node"].attributes.current = current;
this[current + "_node"].attributes.parent = parent;
this[parent + "_node"].appendChild(this[current + "_node"]);
}
groups_tree.dataProvider = xml_object;
}
If you have any questions, feel free to ask.