I'm trying to set the selectedItem for the given example. But I'm having all 
sorts of problems. 

The tree's dataprovider is XML. I'm only interested in selecting the child 
nodes (@label == "Receipt")....that means I have to expand the menu as well.

Can someone give me some ideas?

Code ->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
        
  <mx:Button label="test" click="test()"/>
  <mx:Tree id="menuTree" labelField="@label" width="40%" height="90%" 
showRoot="false" dataProvider="{menu_data}"/>
        
   <mx:Script>
     <![CDATA[
                        
        public function test():void
        {
          //this is failing miserably- doesn't expandItem and adds
          // some other rubbish to the tree
          menuTree.selectedItem = 
XML(menuTree.dataProvider[0]).node.node.(@label == "Receipt");

        }
      ]]>
    </mx:Script>
        
    <mx:XML id="menu_data" xmlns="">
      <MenuOne>
         <node label="Receiving">
           <node title="Purchase Order" label="Purchase Order" />
           <node title="Receipt" label="Receipt" />
          </node>
          <node label="Inventory">
             <node title="Stock SKU" label="Stock SKU" />
             <node title="Stock Slot" label="Stock Slot" />
           </node>
      </MenuOne>
    </mx:XML>
</mx:Application>

Reply via email to