You appear to be dispatching the event from the Application but listening for it on a ModuleWrapper which is some descendant of the Application. That's not how events work. Unless you use the capture or bubble phases, you have to register on the object which is dispatching the event. And if you do use the capture or bubble phases, you have to listen on an ancestor of the object which is dispatching the event. Gordon Smith Adobe Flex SDK Team
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of brett.hitzel Sent: Monday, February 04, 2008 11:24 AM To: [email protected] Subject: [flexcoders] Re: Event Propigation Update I was thinking that maybe the reason the below did not work was because I was adding the event listener before the object was added to the display, so I moved the event handler addition after adding modContainer to workspace_canvas. Unfortunately that did not help. Updated function follows: private function moduleLoadComplete(event:ModuleEvent):void { // The module itself as a Display Object. var visual:DisplayObject = event.module.factory.create() as DisplayObject; // The module container. var modContainer:ModuleWrapper = new ModuleWrapper(); modContainer.id = "module_container" + this._moduleIndex; // Add module to the container. modContainer.addChild(visual); &n! bsp; // Add module container to workspace canvas. root_canvas.workspace_canvas.addChild(modContainer); // Add event listeners to the modContainer. modContainer.addEventListener("profileDataUpdated",profileDataUpdatedHan dler); this._moduleIndex++; } --- In [email protected], "brett.hitzel" <[EMAIL PROTECTED]> wrote: > > Thanks for the reply and apologies for the late response. > > Unfortunately, your second idea may not be practical in my application > as it will only be certain modules listening for these events (what > modules listen to what events would be determined at load time as an XML > configuration file is loaded). > > I have tried your other idea, setting the event listener on the mo! dule > as it is being dynamically created and then dispa! tching t he event from > the parent, unfortunately that did not seem to work. Code samples below: > > RootApplicationFunctions.as(script included on root most application > file so this would be the "parent application") > * NOTE: This function is a couple functions down the chain, originating > from a loop which is iterating over the XML configuration file. It tells > the applications what modules to load. * > private function moduleLoadComplete(event:ModuleEvent):void > { > // The module itself as a Display Object. > var visual:DisplayObject = event.module.factory.create() as > DisplayObject; > // The module container. > var modContainer:ModuleWrapper = new ModuleWrapper(); > modContainer.id = "module_container" + this._moduleIndex; > // Add event listeners to the modContainer. > ! > modContainer.addEventListener("profileDataUpdated",profileDataUpdatedHan \ > dler); > // Add module to the container. > modContainer.addChild(visual); > // Add module container to workspace canvas. > root_canvas.workspace_canvas.addChild(modContainer); > this._moduleIndex++; > } > > private function sendEvent():void > { > dispatchEvent(new Event("profileDataUpdated")); > } > > I did know if it would be looking for profileDataUpdatedHandler in the > parentApplication or in the moduleWrapper as file itself, so at present > this function exists in both spots: > > public function profileDataUpdatedHandler(event:Event):void > { > Alert.show("module container heard the event: " + > event.target.toString()); > } > > RootApplication.! mxm l (this is the file which includes > RootApplicationFunctions.as above) > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > xmlns:view="view.*" > layout="absolute" > width="100%" > height="100%" > creationComplete="rootApplicationInit()"> > > <mx:Style source="asset/style/CommunityUI.css" /> > > <mx:Script source="RootApplicationFunctions.as" /> > > <mx:XML id="OEMConfiguration" source="xml/oemConfiguration.xml" /> > > <view:RootCanvas id="root_canvas" /> > <mx:Button click="sendEvent()" /> > </mx:Application> > > > As of yet, I have not been able to get th! is to work. If I click on the > button on the root, it does fire sendEvent(), but module being loaded is > not responding (technically it is the ModuleWrapper listening, but the > ModuleWrapper passes instructions to the module contained within). > > I have other options available to me I suppose, however this is the way > I would like to do it because it seems like the cleanest way. > > --- In [email protected], "phipzkillah" phil@ wrote: > > > > It's possible. > > > > Main.mxml > > //script > > private function init():void{ > > child1.addEventListener("change", > callBackFunction); > > } > > > > private function dispatchEventsToChildren():void{ > > //call this to dispatch an event > > dispatchE! vent(new Event("change")); > > }> & gt; > > //or do it this way > > private function controlChildren(event:ItemClickEvent):void{ > > child1.publicFunctionUpdateData(args); > > } > > > > > > //body > > <com:child1 id="child1"/> > > <mx:DateField change="controlChildren(event)"/> > > > > > > Child1.mxml > > Some component you have... > > > > > > --- In [email protected], "brett.hitzel" brett.hitzel@ > > wrote: > > > > > > Hi Everyone, > > > > > > I have been charged to architect a fairly large scale Flex > application > > > (first time doing so). I don't think that my issue warrants code > > > samples however if needed I can provide. > > > > > > I have not worked with even! ts too much, but I understand the default > > > three phases it goes through (capture,target,bubble). The > application > > > will be comprised of an application which load a custom MXML > component > > > (basically an extended Canvas), which in turn loads modules based on > > > user interaction. What I need to have happen, is when the root > > > (parentApplication) has values that update, I would like for it to > > > dispatch an event, which the Modules listen for, and then in > response > > > poll the parent for that data to get the new information. > > > > > > Based on everything I have read, events don't propigate in that > > > direction (it climbs down the chain from the top, hits the target, > and > > > then climbs back up). However, is it possible to make it go the > other > > > way? Can chi! ldren hear events of the parent? If this is impossible, >! ; > & gt; does anyone have any thoughts or suggestions for an alternative to > my > > > particular problem? > > > > > > I appreciate any advice you can offer! > > > > > >

