2 Replies Latest reply on Jul 5, 2007 12:06 PM by ntsiii

    expandItem - Bug or Reeeeealy bad documentation?

    DeusAquilus
      Using the Adobe "Handling Tree control events" page method of handling events expandItem does not work if you call a XMLTree1.dataProvider=MainBox command. It only works if you put the XMLListCollection right under the tree.

      To clarify, what if instead of this:
      <mx:Tree id="XMLtree1" width="150" height="170"
      labelField="@label" itemOpen="itemOpenEvt(event);"
      change="changeEvt(event);">
      <mx:XMLListCollection id="MailBox">
      <mx:XMLList>
      <node label="Mail" data="100">
      <node label="Inbox" data="70"/>
      <node label="Personal Folder" data="10">
      <node label="Business" data="2"/>
      <node label="Demo" data="3"/>
      <node label="Personal" data="0" isBranch="true" />
      <node label="Saved Mail" data="5" />
      </node>
      <node label="Sent" data="15"/>
      <node label="Trash" data="5"/>
      </node>
      </mx:XMLList>
      </mx:XMLListCollection>
      </mx:Tree>

      I do this:
      <mx:Tree id="XMLTree1" width="150" height="170"
      labelField="@label" creationComplete="initTree();" />

      <mx:XMLListCollection id="MailBox" >
      <mx:XMLList>
      <root label="Mail" data="100">
      <node label="Inbox" data="70"/>
      <node label="Personal Folder" data="10">
      <node label="Business" data="2"/>
      <node label="Demo" data="3"/>
      <node label="Personal" data="0" isBranch="true" />
      <node label="Saved Mail" data="5" />
      </node>
      <node label="Sent" data="15"/>
      <node label="Trash" data="5"/>
      </root>
      </mx:XMLList>
      </mx:XMLListCollection>

      and call a XMLTree.dataProvider = MailBox command in the initTree(); constructor like so:

      private function initTree():void {
      XMLTree1.dataProvider = MailBox;
      XMLTree1.expandItem(MailBox.getItemAt(0), true); //this does not work
      }

      In this case expandItem does not work (the tree just stays closed). Also in debug mode, I could see the firstVisibleItem in XMLTreeList1 equal to '<exception throw by getter>'. What is the problem here? Is there some other way I am supposed to set the tree's data provider? If so, how?