So now I have this, which works but I think its ugly and probably not the right way
private function expandall(inTree:Tree):void
{
var Dnode:Object;
for (var i:int = 0; i < inTree.dataProvider.getLength(); i ++)
{
Dnode = inTree.dataProvider.getItemAt(i);
if (Dnode != null)
{
trace(Dnode, Dnode.text ,Dnode.isBranch, Dnode.children, inTree.isBranchOpen(Dnode));
inTree.toggleBranch(Dnode, true);
}
for (var j:int = 0; j < Dnode.children.length; j ++)
{
var Enode:Object = Dnode.children[j];
if (Enode != null)
{
trace(Enode, Enode.text ,Enode.isBranch, Enode.children, inTree.isBranchOpen(Enode));
inTree.toggleBranch(Enode, true);
}
for (var k:int = 0; k < Enode.children.length; k ++)
{
var Pnode:Object = Enode.children[k];
if (Pnode != null)
{
trace(Pnode, Pnode.text ,Pnode.isBranch, Pnode.children, inTree.isBranchOpen(Pnode));
inTree.toggleBranch(Enode, true)
}
for (var l:int = 0; l < Enode.children.length; l ++)
{
var Anode:Object = Pnode.children[l];
if (Anode != null)
{
trace(Anode, Anode.text ,Anode.isBranch, Anode.children, inTree.isBranchOpen(Anode));
inTree.toggleBranch(Anode, true)
}
}
}
}
}
trace()
}
Then I did this but it I still feel it is not how you are supposed to do it:
private function collapseall(inTree:Tree):void
{
for (var i:int = 0; i < inTree.dataProvider.getLength(); i ++)
{
var Dnode:Object = inTree.dataProvider.getItemAt(i);
if (inTree.dataProvider.isBranch(Dnode))
{
trace(Dnode, Dnode.text ,Dnode.isBranch, Dnode.children, inTree.isBranchOpen(Dnode));
inTree.toggleBranch(Dnode, false);
for each(var Enode:Object in Dnode.children)
{
if (inTree.dataProvider.isBranch(Dnode))
{
trace(Enode, Enode.text ,Enode.isBranch, Enode.children, inTree.isBranchOpen(Enode));
inTree.toggleBranch(Enode, false);
for each(var Pnode:Object in Enode.children)
{
if (inTree.dataProvider.isBranch(Pnode))
{
trace(Pnode, Pnode.text ,Pnode.isBranch, Pnode.children, inTree.isBranchOpen(Pnode));
inTree.toggleBranch(Enode, false)
for each(var Anode:Object in Enode.children)
{
if (inTree.dataProvider.isBranch(Anode))
{
trace(Anode, Anode.text ,Anode.isBranch, Anode.children, inTree.isBranchOpen(Anode));
inTree.toggleBranch(Anode, false)
}
}
}
}
}
}
}
}
trace()
}