views:

2910

answers:

1

I am using a Tree control with an XMLListContainer dataProvider.... I use an itemOpen event with the following code to update another data provider when a tree folder is opened (using small triangle) - the data provider contains all the <slide /> elements in that particular tree folder...

private function itemOpenEvent(event:TreeEvent):void {    
 slideDP = new XMLListCollection(event.item.elements("slide"));  
 slideDP.refresh();           
}

If a second folder is opened thumbDP updates fine but when the first folder (or another closed folder) is clicked I want the same behaviour to happen (currently you have to close and reopen the first folder)

So I use a itemClick event - but this fires a ListEvent and I can't work out how to get the child elements from the XMLListContainer as easy... The code below throws an out of bounds exception

private function itemClickEvent(event:ListEvent):void {   
 treeFeed.getItemAt(event.rowIndex);              
}

Can anyone help? Thanks :)

+1  A: 

I would change your event listener to listen for a change Event, and use the selectedItem property of the Tree:

private function changeHandler(event:ListEvent):void
{                  
    slideDP = new XMLListCollection(tree.selectedItem.elements("slide"));

    slideDP.refresh();                           
}

You may need to cast selectedItem as XML or XMLList.

Eric Belair