Tree is a UI component that offers a convenient representation of hierarchical information (file folders, product catalogs, nested categories, etc.). The Astra Tree is built on top of the Flash CS3 List Component and is provided with a default TreeCellRenderer.
Using Tree in Flash CS3
In Getting Started, we created a simple Tree and populated it with content. Let's reuse the Tree we created, and add an event listener to respond to the user clicking on Tree items.
First, let's import the ListEvent class and the TextField class. Since Tree inherits from List, most of the events it dispatches are List events. We'll use the TextField to display the label of the item the user clicks on.
Next, let's add a TextField to stage:
Now, let's add an event listener that will be called whenever the user clicks on items in the tree:
Now we can actually write the function that will parse the event. In this function, the content of the textfield is set to the label of the item that's been clicked on. In lieu of the label, we can also refer to any of the attribute names of the original XML node.
For additional information, please take a look at the Examples section for functional demonstrations and the ActionScript 3.0 Class Reference for full details on every property, method, and style available to the Tree component.