Instead of going through the index, you could iterate the selectedItems
and use e4x syntax to get the attribute you're looking for. selectedItem
and selectedItems are a direct link to the object in the dataprovider,
in this case XML objects:
 
        private function onItemClick(event:ListEvent):void
      {
        trace("******");
        for each (var item in tree1.selectedItems)
        {
          trace([EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> );
        }
      }
 
For your sample XMLListCollection, selecting a single item (in this
example the 1st) will yield:
 
******
1
 
And selecting all will yield:
 
******
76
3
1
 
HTH,
Ryan

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of digital_eyezed
Sent: Wednesday, October 29, 2008 8:42 AM
To: [email protected]
Subject: [flexcoders] Please explain the Tree to me!!!!! Before I die
waiting!



Hi,

I have a tree filled with an XMLListCollection, all nodes are named
<node>.

The structure is like this:

<node locationid='1'>
<node locationid='3'>
<node locationid='76'/>
</node>
</node>

but on a much greater scale.

Now I have set the Tree component to allowMultipleSelection=true so
that the user can select multiple nodes, that works no problem. I have
also set an itemClick function to trigger when the user selects the
item or items. By doing this I can work out if one item is selected
or multiple:

if(Tree(event.target).selectedItem){
dosomethingforoneselection; //this works ok
}else if(Tree(event.target).selectedIndicies){
for(var i:int = 0;i<Tree(event.target).selectedIndicies.length;i++){
var h:int = int(Tree(event.target).selectedIndicies[i];
}
}

Ok, now I have the index of each item selected on the Tree, so how do
I get the locationid from the index?

Completely mind boggled!

Thanks ever so much if you can help!

Kind Regards,

Iain



 


This message is private and confidential. If you have received it in error, 
please notify the sender and remove it from your system.

Reply via email to