Mark,
This is really the line that I was looking for:
tree.setPropertiesAt(tree.getDisplayIndex(node)+2,
{backgroundColor:0xff0000});
I completely missed the setPropertiesAt() method when going through the
documentation :|
Now, about the logic there is no problem, I am ATM only looking for the
parent node of the selected node, which works fine when you do something
like this:
tree.setPropertiesAt(tree.getDisplayIndex(tree.selectedNode.parentNode),
{backgroundColor:0xff0000});
The only problem with all this stuff is that I am using "tree.setStyle" to
set different background colors, depending on their depth:
tree.setStyle("depthColors", [0x00ff00, 0x0000ff]);
When using this, for some reason, the setPropertiesAt() method doesnt work
(bug maybe?), To solve this, I am now going to go through the different rows
and setting their different initial background colors, to later on be able
to modify them.
Funny problems you run into when dealing with components :)
Thanks again Mark.
Claudia
From: "Mark Mulhollam" <[EMAIL PROTECTED]>
Reply-To: Flashcoders mailing list <[email protected]>
To: "Flashcoders mailing list" <[email protected]>
Subject: RE: [Flashcoders] Modifying Tree components highlight
Date: Tue, 25 Oct 2005 06:02:23 -0500
Claudia,
I think you can get there by doing something like the following. The
tricky
part is figuring out the relationship of the other node to highlight to the
node
you are presently selecting. Here I just highlighted two nodes down the
tree.
Note that the tree only considers open nodes in its displayIndex count.
What
happens if you first open a branch in between the two nodes I haven't
checked.
And it highlights two nodes down even if you immediately thereafter close
that
branch - so order is important. I.e., what is displayed at the time
changes the
index of all nodes.
myTreeListener.change = function(evtObj) {
var tree = evtObj.target;
var node = tree.selectedItem;
tree.setPropertiesAt(tree.getDisplayIndex(node)+2,
{backgroundColor:0xff0000});
// var openNode = tree.getIsOpen(node);
// var isBranch = tree.getIsBranch(node);
// possible logic ala : if (tree.attributes.label == "nodeLabel3") { then
highlight tree.attributes.nodeToHighlight; }
// xml : <node label="nodeLabel3" nodeToHighlight="allBlahNodes"/>
// <node label="nodelabel8" nodeToHighlight="allDarnNodes"/>
// <node label="nodeLabelX" linkedNode="allBlahNodes"/>
// <node label="nodeLabelX" linkedNode="allDarnNodes"/>
// I suppose you could loop through DISPLAYED nodes looking for any
attribute
you want and changing that node
// of course you could always loop through your all or some part of your
tree
nodes
// You will have to modify to skip current selected node
// for (i=0; i<tree.rowCount;i++) {
// var checkNode = tree.getNodeDisplayedAt(i);
// if (checkNode.attributes.linkedNode == node.attributes.nodeToHighlight)
{
// tree.setPropertiesAt(tree.getDisplayIndex(checkNode),
{backgroundColor:0xff0000});
// break;
// }
// } completely untested!!!
}
Nodes will remain highlighted until you change their color again, so you
may
need to keep track of the last highlighted node to reset it back to
default.
Mark Mulhollam
Minneapolis, Minnesota
_________________________________________________________________
MSN Messenger 7.5 is now out. Download it for FREE here.
http://messenger.msn.co.uk
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders