What happened in onModuleLoaded? I think you should add the eventlistener before setting the url or calling loadModule()
Thanks, Gaurav -----Original Message----- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of dbronk Sent: Monday, January 28, 2008 4:36 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Module hell... Flex 3 I'm trying to get something very basic to work with modules. I have my app and two swf modules (Form1.swf and Form2.swf). Each test module simply has a couple TextInput fields. I have also extended Module so I can follow what is going on and I will be adding custom code later. MyModule extends Module has: public function MyModule() { super(); trace("Module constructor"); addEventListener(FlexEvent.INITIALIZE, onInitialize); } protected function onInitialize(event:Event) : void { trace("Module.onInit: " + this.toString()); dispatchEvent(new BaseEvent("moduleLoaded", this, true, true)); } Very basic. I want to be notified when the Module is initialized. When I have the following code inline to a button click which will load the module it works fine var moduleLoader : ModuleLoader = new ModuleLoader(); moduleLoader.id = moduleName; moduleLoader.url = moduleName; moduleLoader.loadModule(); moduleLoader.addEventListener("moduleLoaded", onModuleLoaded); moduleStackChild = moduleLoader; moduleStack.addChild(moduleStackChild); moduleMap.put(moduleName, moduleStackChild); My onModuleLoaded function gets called. Now for the issue. If I take this code and place it into a common object it no longer works THE FIRST TIME. I have two buttons, one to load Form1.swf and the other to load Form2.swf. When this code to load the module is in a separate class, it doesn't matter if I click button 1 or 2 first. It simply will not work on the first click. Second click and beyond work fine. Also, in debug mode, works great every time. What happens is that the last thing that runs is the loadModule() command. The constructor on MyModule never executes on the first execution. Future executions work fine. I'm hoping I explained this good enough as it is very strange. But I definitely want to have this function in my util classes and not have to duplicate the code all over the place. Suggestions? Thanks, Dale -- 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