import mx.controls.List;
import mx.controls.DataGrid;
// type your components
var listBox:List;
var dataGrid:DataGrid;
// create arrays containing objects with your data
var fruits:Array = new Array({name:'apple', weight:2, price:150}, {name:'mango', weight:3, price:140}, {name:'grape', weight:5, price:120});
var vegetables:Array = new Array({name:'brinjal', weight:2, price:150}, {name:'radish', weight:3, price:140}, {name:'potatoe', weight:5, price:120});
var flowers:Array = new Array({name:'rose', weight:2, price:150}, {name:'lily', weight:3, price:140}, {name:'sun', weight:5, price:120});
// array containing info for the list box
var main:Array = new Array({label:'Fruits', data:fruits}, {label:'Vegetables', data:vegetables}, {label:'Flowers', data:flowers});
// set data provider for the list box to main array
listBox.dataProvider = main;
// set up listener for the list box so that when changed, it will populate the datagrid with associated info
var listener:Object = new Object();
listener.change = function(pEvent:Object) {
     var selectItem:Object = pEvent.target.selectedItem;
     dataGrid.dataProvider = selectItem.data;
};
listBox.addEventListener('change', listener);
myButtonListener = new Object();
myButtonListener.click = function() {
     trace("You clicked the button! Tsk, tsk!");
};
myButton.addEventListener("click", myButtonListener);