Handling mySQL Results From AMFPHP in AS3

switch(typeof(result)){

	case "boolean":

		//Convert to string and place in text box
		myTextBox.text = result.toString();
		break;

	case "number":

		//Convert to string and place in text box
		myTextBox.text =  result.toString();
		break;

	case "object":

		//Create an array of values
		var values:Array = result.serverInfo.initialData;

		//Create an array of column names
		var category:Array = result.serverInfo.columnNames;

		var aArr:Array = new Array();

			for (var i:Number=0; i < values.length; i++) {

 				aArr[i] = new Object();

 				for (var aIndex:* in category) {

 				 aArr[i][category[aIndex]] = values[i][aIndex];

 				}
 			}

		//Create a new Data Provider
		var dp:DataProvider = new DataProvider(aArr);

		//Assume we have a datagrid we wish to bind to
		myDataGrid.removeAllColumns();

		//Bind the Data Provider to the Data Grid
		myDataGrid.dataProvider = dp;

		//Get the row count
		myDataGrid.rowCount = aDg.length;
		myDataGrid.setSize(500,100);
		break;

	case "string":
		myTextBox.text = result.toString();

	default:
		break;
}