If you are using xml in your tree, you can use e4x to manipulate which
item you want to be selected by searching with e4x... 

for example:

import mx.events.*
import mx.rpc.events.*;
import mx.collections.*;

[Bindable]      
public var treeCollection:XML;  

/***** this would be in your receivedEvent from your remote object or
http call ****/
treeCollection = new XML(event.result);

/* 
your xml looks like this
<country>
  <state name="Alabama" id="29" type="state">
    <city name="Birmingham" id="233" stateID="29" type="city" />
    <city name="Mobile" id="234" stateID="29" type="city" />
    <city name="Montgomery" id="235" stateID="29" type="city" />
  </state>
</country>
*/

<mx:Tree x="10" y="30" 
  id="activeTree" dataProvider="{treeCollection}" 
  labelField="@name" change="treeChange();" height="436" 
  showRoot="false" width="162"/>        

say i want to select Mobile from the tree with actionscript, and i
want my "change" event to happen, just like somebody clicked on it....

private function refetchCurrentCity(cityID:Number):void{
activeTree.selectedItem = treeCollection.state.city.(@id==cityID);
activeTree.dispatchEvent(new Event("change"));
}

your treeCollection is already xml so you can go ahead and tear it up
using the very awesome e4x! and then dispatch your change event or
click event....

I'm not even sure if thats what your going for... but maybe that will
help...



Reply via email to