isn't that what bubbling is for? dispatchEvent(new Event("myEvent",true));
http://www.rubenswieringa.com/blog/eventbubbles-eventcancelable-and-eventcurrenttarget
------
Sherif Abdou
http://VadexFX.com
http://Sherifabdou.com
----- Original Message -----
From: sleblang
To: [email protected]
Sent: Sunday, September 07, 2008 12:29 AM
Subject: [flexcoders] Capture custom component event in parent application
(application.mxml)
What's the best way to capture an event (i.e. button click) from a custom
component in a parent container. Would I want to have the button click event
call a handler in the component and then from the handler dispatch a custom
event or is there a better way? Here's some code to help illustrate:
//CustomComponent
<mx:Script>
<![CDATA[
public function exitHandler(event:MouseEvent):void {
var myEventObj:Event = new Event( "myCustomEvent" );
dispatchEvent( myEventObj );
}
]]>
</mx:Script>
<mx:Metadata>
[ Event( name="myCustomEvent", type="flash.events.Event") ]
</mx:Metadata>
<mx:Button id="" label="Cancel" width="65" textAlign="center"
click="exitHandler()"/>
// End CustomComponent
// parent container (i.e. Application.mxml)
<mx:Script>
<![CDATA[
public function someEventHandler(event:MouseEvent):void {
// execute ....
}
]]>
</mx:Script>
<sx:CustomComponent myCustomEvent="someEventHandler()" />
Thanks for the assistance.