height="600">
import mx.events.*;
import mx.collections.*;
public function addPerson():void {
ac.addItem({first:firstInput.text, last:lastInput.text,email:emailInput.text});
clearInputs();
}
public function removePerson():void {
if (dg.selectedIndex >= 0) {
ac.removeItemAt(dg.selectedIndex);
}
}
public function updatePerson():void {
if (dg.selectedItem !== null) {
ac.setItemAt({first:firstInput.text, last:lastInput.text,email:emailInput.text}, dg.selectedIndex);
}
}
public function dgChangeHandler():void {
clearInputs();
firstInput.text = dg.selectedItem.first;
lastInput.text = dg.selectedItem.last;
emailInput.text = dg.selectedItem.email;
}
public function clearInputs():void {
firstInput.text = "";
lastInput.text = "";
emailInput.text = "";
}
public function myLabelFunc(item:Object):String {
return item.first + " " + item.last;
}