Looks ok to me.

 

The event is bubbling, so try listening for the event at the Main app
level:

this.addEventListener('dgItemClick', CtgsPnlDGItemClick)

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of rss181919
Sent: Wednesday, August 06, 2008 3:38 PM
To: [email protected]
Subject: [flexcoders] Re: Custom Events

 

I have listed my setup below. 
Results:
I have confirmed that the initialize event on the parent object adds 
the event.
Clicking the item on the grid, fires the internal handler and I have 
confirmed that it dispatches the custom event. However, the parent 
event handler for the custom event does not fire.

My call to the custom component looks like this:

<pdb:CategoriesPnl id="CategoriesPnl" 
initialize="CategoriesPnl.CtgsPnlDG.addEventListener('dgItemClick', 
CtgsPnlDGItemClick);"></pdb:CategoriesPnl>

The eventhandler in the parent looks like this:

private function CtgsPnlDGItemClick(event:ListEvent):void
{Alert.show(event.eventPhase+'_external');}

The custom component looks like this:
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " 
label="Categories" backgroundColor="#FFFFCC" width="100%" 
height="100%"> 
<mx:Script>
<![CDATA[
import flash.events.Event;
import mx.collections.ArrayCollection;
import mx.controls.DataGrid;
import mx.controls.Alert;
import mx.events.*
import mx.events.ListEvent
[Bindable] public var CtgsPnlAC:ArrayCollection = new 
ArrayCollection;
private function CtgsPnlDGItemClick(event:ListEvent):void
{
Alert.show('internal');
Alert.show('dispatch result'+dispatchEvent(new Event
("dgItemClick",true)).toString());
}
private function CtgsPnlDGRefresh():void
{
CtgsPnlWebSvcVO.GetAllCategories();
}
]]>
</mx:Script> 
<mx:Metadata>
[Event(name="dgItemClick", type="mx.events.ListEvent.ITEM_CLICK")]
</mx:Metadata>
<mx:WebService id="CtgsPnlWebSvcVO" 
wsdl="http://support07:57773/csp/prtest/pdb.sl.WebServiceVO.cls?
<http://support07:57773/csp/prtest/pdb.sl.WebServiceVO.cls?> 
WSDL=1">
<mx:operation name="GetAllCategories" resultFormat="object" 
fault="mx.controls.Alert.show(event.fault.faultString)"
result="CtgsPnlAC = event.result.Categories;">
</mx:operation>
</mx:WebService>
<mx:DataGrid id="CtgsPnlDG" height="100%" 
dataProvider="{CtgsPnlAC}" 
initialize="CtgsPnlDGRefresh()" 
itemClick="CtgsPnlDGItemClick(event)"
>
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="CtgId"/>
<mx:DataGridColumn headerText="Key" dataField="CtgKey"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> "...firing an handler off the itemSelect event and then in the 
handler
> creating a new event and dispatching that to an external handler"
> 
> That is how I do it. What didn't work?
> 
> Tracy

 

Reply via email to