When I create something like the following:
<mx:DataGrid id"myDataGrid"
itemEditBegin="myDataGrid_itemEditBeginHandler(event)" />
When does the event listener for “itemEditBegin” get added and removed? Is this essentially the same as:
<mx:DataGrid id="myDataGrid"
creationComplete="myDataGrid_creationCompleteHandler(event)" />
protected function myDataGrid_creationCompleteHandler(event:FlexEvent):void
{
this.myDataGrid.addEventListener(DataGridEvent.ITEM_EDIT_BEGIN,
this.myDataGrid_itemEditBeginHandler);
}
protected function myDataGrid_whatEventDispatcherGoesHere?Handler(event:FlexEvent):void
{
this.myDataGrid.removeEventListener(DataGridEvent.ITEM_EDIT_BEGIN,
this.myDataGrid_itemEditBeginHandler);
}
Basically, I’m wondering where I should add “myDataGrid.addEventListener” if I want to do it programmatically? Should it be in the creationComplete listener function of the object itself, or perhaps in the creationComplete listener function for whatever parent object it resides in?
If you’re adding the event listener programmatically:
Good reference for object creation in Flex: http://www.mikaflex.com/?p=270