Define Array in ActionScript by a comma-separated list of values surrounded by braces
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp()">
<mx:Script>
public function initApp():void {
myTree.setStyle("depthColors",[0xFFCC33, 0xFFCC99, 0xCC9900]);
myTree.setStyle("alternatingItemColors",["red", "green"]);
}
</mx:Script>
<mx:XMLList id="treeData">
<node label="File">
<node label="Save">
<node label="Doc" />
<node label="Pdf" />
<node label="Rdf" />
</node>
<node label="Edit">
<node label="Cut" />
<node label="Copy" />
<node label="Paste" />
</node>
<node label="Window" />
<node label="Help" />
</node>
</mx:XMLList>
<mx:Panel title="Tree Control Example" width="100%">
<mx:Tree id="myTree" width="100%" labelField="@label" dataProvider="{treeData}" />
</mx:Panel>
</mx:Application>
Related examples in the same category