You should be able to just do parent.addEventListener("showType", ...)
Matt -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rich Kroll Sent: Monday, January 16, 2006 2:48 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Flex2 Custom Component Event Hello all, I'm new to this list and am glad to join the community. I've been working with flex 2 and have run into a problem I'm hoping someone here might be able to help me solve. I'm dispatching an event in my main mxml file, and need to have it be captured within a custom component I've created. The problem I'm having is that the custom component is created numerous times from within an <mx:Repeater> so I can't seem to attach the listener in the correct fashion. Here is a snipped from my main app: <mx:Script> import mx.collections.ArrayCollection; import flash.util.trace; public function broadcastShowType() { dispatchEvent(new Event("showType")); mx.controls.Alert.show("broadcast show event"); } </mx:Script> <mx:Repeater id="list" dataProvider="{inventory}"> <mx:GridItem > <inventoryItem id="invItem" invItem="{list.currentItem}" /> </mx:GridItem> </mx:Repeater> Then within my component I've got: <mx:Script> private function initComponent() { addEventListener("showType", handleShowType); } private function handleShowType(event) { Alert.show("Received Event Notification"); } </mx:Script> I assumed that putting the addEventListener() within the component would create it when the component was created, but it seems to be a local listener, and will not receive events from the main app. Considering the dynamic nature of how I'm creating the custom component, is there another way to add the event listener and have it able to respond to the outer events? Rich Kroll -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/