Flextrine Tutorial – CRUD in a simple Flex 4 address book: Deleting entities_
Aug 03, 2010
<s:Button label="Delete" click="onDeleteClick()" enabled="{tree.selectedItem != null}" />

And implement the onDeleteClick() method:

private function onDeleteClick():void {
  em.remove(tree.selectedItem);

  if (tree.selectedItem is Contact)
    tree.selectedItem.contactGroup.removeContact(tree.selectedItem);
}

Notice that we maintain the bi-directional association if the deleted item is a contact by removing it from its associated contactGroup.

And that’s it :)  The entity will be removed from its entity repository (updating the tree via databinding) and on the next flush() it will be removed from the database.

The final step in our little address book is to allow the user to update existing entities.