I’m using a Datagrid which has an itemRenderer that contains an image :
protected static function hbox1_clickHandler(event:MouseEvent):void
{
//some action
}
<mx:DataGrid id="reportDG" dataProvider="{CDODReportsModel.instance.reportDataArrayCollectionObject}" color="black" horizontalScrollPolicy="on">
<mx:columns>
<mx:DataGridColumn headerText="info">
<mx:itemRenderer>
<fx:Component>
<mx:HBox horizontalAlign="center">
<mx:Image source="assets/images/i_info.png" scaleX="0.6" scaleY="0.6" click="hbox1_clickHandler(event)"/>
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="NAME" headerText="NAME"/>
<mx:DataGridColumn dataField="TOTAL" headerText="TOTAL"/>
</mx:columns>
</mx:DataGrid>
I want to dispatch an event on click, so when I click on the image I do an action. However, It is giving me an error when do that. I did some search and the suggested answers were using outerDocument and ParentDoecument .. both didn’t work.
How can I access the click handler function (hbox1_clickHandler() in my code) ?
I dont think that this is possible if you are in Application class.
If this is some other class, than you can just wright something like this:
Also this is not the best idea to wright inline item renderes. The best approach is to extend base item Renderer and make your own one. Also you can extend flash Event class and make your own. Doing this gives you possibility to send some additional data with your event.
But anyway, using yours approach code will be like this: