Mega Code Archive

 
Categories / Flex / Components
 

Use ActionScript to set up the data provider for Tree control

<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="creationCompleteHandler(event)">     <mx:Script>                      import mx.collections.ArrayCollection;             import mx.controls.List;             private function creationCompleteHandler(event:Event):void {                 var array:Array = new Array({label: "CA", children: new Array(                                                       {label: "Los Angeles"},                                                       {label: "San Francisco"})},                                             {label: "MA", children: new Array(                                                       {label: "Boston"})});                 var collection:ArrayCollection = new ArrayCollection(array);                 tree.dataProvider = collection;             }            </mx:Script>     <mx:Tree id="tree" labelField="label" width="200" /> </mx:Application>