This is my second day using FLEX and AS 3.0 so I am very new at this. I am trying to obtain the value of the selected item in a tree component, in this case it is just a name. Below is the tree I have created. The tree contents have been populated programmatically with an array called “cat”. The tree gets populated just fine but I can’t figure out how to get the name of the currently selected item.
<mx:Tree id="category_tree" x="10" y="80" width="160" height="169" showRoot="true" dataProvider="{cat}" labelField="name">
I have used the selectedItem.toString() function but this only seems to return the type of object and not the value. Currently it returns “object Object”
In my script I have…
category_tree.selectedItem.toString();
Any help on this would be greatly appreciated. Thank you in advance for your time.
You can add a change event to the tree and have use a callback similar to:
or access the value directly