Brad try this. Hope it helps
Mike
//handle tree node selections
function bgTreeCall(component) {
//identify selected node
var s = component.getSelectedNode();
//check for double-click
checkDblClick(s);
//toggle folder state on double-click
if (s.isBranch() && dClick) {
toggleOpen = ((s.isOpen()) ? false : true);
s.setIsOpen(toggleOpen);
t.refresh();
saveBranches();
} else {
//get new data on first click
if (!dClick) cD = s.getData();
//process data
cD.update();
}
}
//restore tree to last saved state
function setBranches() {
fL = this.bg_so.data.folderList;
rO = this.bg_so.data.rootOpen;
if (fL == undefined) {
//define default state
t.getRootNode().setIsOpen(true);
} else {
t.getRootNode().setIsOpen(rO);
var bArray = t.getRootNode().getChildNodes();
var i = 0;
setBranchesLoop(bArray,fL,i);
}
t.refresh();
}
function setBranchesLoop(bArray,fL,i) {
for (var j=0; j<bArray.length; j++) {
if (bArray[j].isBranch()) {
bArray[j].setIsOpen(fl[i]);
i++;
var thisChildren = bArray[j].getChildNodes();
i = setBranchesLoop(thisChildren,fL,i);
}
}
return i;
}
//get tree status when a branch is opened/closed
function saveBranches() {
rOpen = t.getRootNode().isOpen();
var bOpen = new Array();
var bArray = t.getRootNode().getChildNodes();
saveBranchesLoop(bOpen,bArray);
//by defining these parameters as properties of the shared
//object they get automatically saved if the file gets closed
this.bg_so.data.folderList = bOpen;
this.bg_so.data.rootOpen = rOpen;
}
function saveBranchesLoop(bOpen,bArray){
for (var j=0; j<bArray.length; j++) {
if (bArray[j].isBranch()) {
bOpen.push(bArray[j].isOpen());
var thisChildren = bArray[j].getChildNodes();
saveBranchesLoop(bOpen,thisChildren);
}
}
}
[quoted text, click to view] "Brad Berkland" <bberkland@capella.edu> wrote in message
news:c06dkk$bdr$1@forums.macromedia.com...
> Hello
>
> I am using tree components (MX 2004 Pro) to present collections of useful
> links at couple web sites. I would like to be able to store the current
state
> of the tree in a sharedObject when a user clicks on a node so that when
he/she
> returns to the links page, the tree of links has the same branches
> opened/closed as when the user was last there. I have used the
sharedObject and
> understand that part of the problem - what I need to know is how I go
about
> getting a snapshot of the tree and its branches so I can save that data.
Thanks
> for your help
>