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

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Claudia
Barnal
Sent: Monday, October 24, 2005 7:01 PM
To: [email protected]
Subject: [Flashcoders] Modifying Tree components highlight


Hi,

I’ve been given the task to change the highlight programmatically of the
different nodes in a tree component.

The functionality would be something like this:

The user selects a node (highlighting it), then based on some event, another
node in the tree is highlighted with a DIFFERENT color, leaving both nodes
highlighted with their respective default and special colors.

That’s the basic functionality I’m looking after. I digged through the
source and found that the highlight can be found like this.

for(var i:Number = 0; i < treeInstance.rows.length; i++)
{
   trace(treeInstance.rows[i].highlight)
}

I tried changing the color of the treeInstance.rows[x].highlight MovieClip,
but found that it is only possible if it is the selected node in the tree
component, even though the for loop indicates that the MC exists.

I also had a look at using treeInstance.cellRenderer = “blah”; But I
couldn’t find any help on that either.

I would really appreciate if you guys could help me find a solution to this
problem (at this stage I’m not fussy about OOP or clean code).

TIA
Caludia

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to