System Manager is the handler for popup windows. So, either add the event listener to the system manager of the application or add it to the system manager of the module.
systemManager.addEventListener('customEventDispatchedByModule', onEvent); --- In flexcoders@yahoogroups.com, "cuttenv" <cutt...@...> wrote: > > Hi valdhor, > Thanks for making a sample! I went back and looked at my code again and > realized I was trying to catch an event that was being dispatched via a Popup > inside the module! > > Application: > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical" > creationComplete="onCreationComplete()"> > <mx:Script> > <![CDATA[ > import mx.events.ModuleEvent; > import mx.modules.IModuleInfo; > import mx.modules.ModuleManager; > import mx.controls.Alert; > > private var modInfo:IModuleInfo; > private var myModule:myMod; > > private function onCreationComplete():void > { > modInfo = ModuleManager.getModule('myMod.swf'); > modInfo.addEventListener(ModuleEvent.READY, > onModuleReady); > modInfo.load(); > } > > private function onModuleReady(event:ModuleEvent):void > { > myModule = modInfo.factory.create() as myMod; > addChild(myModule); > > myModule.addEventListener('customEventDispatchedByModule', onEvent); > } > > private function onEvent(event:Event):void > { > Alert.show(event.type, "Event Received!"); > } > ]]> > </mx:Script> > </mx:Application> > > MyMod.mxml: > <?xml version="1.0" encoding="utf-8"?> > <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" > creationComplete="onCreate()"> > <mx:Script> > <![CDATA[ > private var myPopUp:MyPopUp; > private function onCreate():void > { > myPopUp = > MyPopUp(PopUpManager.createPopUp(this,MyPopUp,true)); > PopUpManager.centerPopUp(myPopUp); > } > ]]> > </mx:Script> > <mx:Button label="Dispatch Event" click="doDispatchEvent(event)"/> > </mx:Module> > > my popup > MyMod.mxml: > <?xml version="1.0" encoding="utf-8"?> > <mx:Panel > xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> > <mx:Script> > <![CDATA[ > private function doDispatchEvent(event:MouseEvent):void > { > dispatchEvent(new > Event('customEventDispatchedByModule',true)); > } > ]]> > </mx:Script> > <mx:Button label="Dispatch Event" click="doDispatchEvent(event)"/> > </mx:Panel> > > --- In flexcoders@yahoogroups.com, "valdhor" <valdhorlists@> wrote: > > > > What are MyCustomMdoule (Spelling?) and moduleContent ? > > > > The following works for me: > > > > Application: > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > layout="vertical" > > creationComplete="onCreationComplete()"> > > <mx:Script> > > <![CDATA[ > > import mx.events.ModuleEvent; > > import mx.modules.IModuleInfo; > > import mx.modules.ModuleManager; > > import mx.controls.Alert; > > > > private var modInfo:IModuleInfo; > > private var myModule:myMod; > > > > private function onCreationComplete():void > > { > > modInfo = ModuleManager.getModule('myMod.swf'); > > modInfo.addEventListener(ModuleEvent.READY, > > onModuleReady); > > modInfo.load(); > > } > > > > private function onModuleReady(event:ModuleEvent):void > > { > > myModule = modInfo.factory.create() as myMod; > > addChild(myModule); > > > > myModule.addEventListener('customEventDispatchedByModule', onEvent); > > } > > > > private function onEvent(event:Event):void > > { > > Alert.show(event.type, "Event Received!"); > > } > > ]]> > > </mx:Script> > > </mx:Application> > > > > MyMod.mxml: > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> > > <mx:Script> > > <![CDATA[ > > private function doDispatchEvent(event:MouseEvent):void > > { > > dispatchEvent(new > > Event('customEventDispatchedByModule',true)); > > } > > ]]> > > </mx:Script> > > <mx:Button label="Dispatch Event" click="doDispatchEvent(event)"/> > > </mx:Module> > > > > > > --- In flexcoders@yahoogroups.com, "cuttenv" <cuttenv@> wrote: > > > > > > I have a rather straight forward question. > > > I am creating a module like this: > > > private var modInfo:IModuleInfo > > > private var myModule:MyCustomMdoule; > > > > > > //In creation complete of application > > > modInfo = ModuleManager.getModule('myMod.swf'); > > > modInfo.addEventListener(ModuleEvent.READY, onModuleReady); > > > modInfo.load(); > > > > > > //In tho onModuleReady command > > > myModule = modInfo.factory.create() as MyCustomModule; > > > moduleContent.addChild( myModule ); > > > myModule.addEventListener( 'customEventDispatchedByModule', onEvent ); > > > > > > //Inside my module there is > > > dispatchEvent( new Event('customEventDispatchedByModule',true) ); > > > > > > Even though the code for the dispatch event is running the handler > > never runs... am I doing something wrong?? or do module not dispatch > > events?? > > > > > >