Accidentally sent this too early... here's what I meant to send: ________________________________
From: Gordon Smith Sent: Wednesday, September 05, 2007 9:19 PM To: '[email protected]' Subject: RE: [flexcoders] Receiving events in itemRenderer custom components not in the line of fire? Here's one way to do it : MyApp.mxml: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:List id="list" dataProvider="{[ 'one', 'two' ]}" itemRenderer="CustomRenderer"/> <mx:Button id="b" click="dispatchEvent(new Event('updateRenderers'))"/> </mx:Application> CustomRendrerer.mxml: <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initializeHandler(event)"> <mx:Script> <![CDATA[ private function initializeHandler(event:Event):void { parentDocument.addEventListener("updateRenderers", updateRenderersHandler); } private function updateRenderersHandler(event:Event):void { customtext.text = "updated"; } ]]> </mx:Script> <mx:TextInput id="customtext"/> </mx:Canvas> Each renderer, when it is initialized, registers to listen for an "updateRenderers" event from its parentDocument, which is the Application.. When the renderer receives the event, it changes the text of its TextInput. The Button causes the Application to dispatch this event. - Gordon ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of enginefloor Sent: Wednesday, September 05, 2007 4:34 PM To: [email protected] Subject: [flexcoders] Receiving events in itemRenderer custom components not in the line of fire? OK, in Flex pseudo-code I have a setup like this: <Application> ... <Panel> <List id='somelist' itemRenderer='CustomRenderer' /> <ControlBar> <Button id='massbutton' buttonDown='??????' /> </ControlBar> </Panel> </Application> <CustomRenderer> <mx:Image /> <mx:TextInput id='customtext' /> </CustomRenderer> So, pictorially, sorta: Application / \ massbutton somelist \ \ \ \ \... CustomRenderer,CustomRenderer,CustomRenderer,... If this comes out right you'll see that massbutton and the CustomRenderers are on different paths from the root of the tree. How can I send fire an event from massbutton that triggers a function in each CustomRenderer, causing all of them to populate their respective customtext with the same value (ideally the payload from a CustomEvent, but we can keep it simple if necessary). If there's an easy way to access the functions in the CustomRenderers directly, from the Application, that would be fine too, since I know how to capture an Event from massbutton in Application. Any help would be appreciated. Thank you very much.

