I would try to build some way so you only request a module once From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Guilherme Blanco Sent: Wednesday, September 17, 2008 7:11 AM To: [email protected] Subject: [flexcoders] Multiple requests to load module do weird behaviors in app
Hi, I'm currently working in an extremely big application written in Flex + PHP + Oracle. It's entirely controlled by modules and events dispatching and listenings to reduce memory overhead. Each app piece is a module which is loaded when requested to be viewed and unloaded when closed. To support this modules dependency, I have this small class that controls the Module loading in my application: http://pastebin.com/f73a59279 Static method Environment.getModuleURLFromPackage does something like: return module.replace( /\./gi, "/" ) + ".swf"; And I implemented a wrapper to DRY module load calls: public static function loadModule(module:String, handler:Function, showProgressInfo:Boolean = false):void { // Registry to prevent multiple instances of same module var m:AdvancedModuleLoader = AdvancedModuleLoader.create(module); m.showProgressInfo = showProgressInfo; m.addEventListener(ModuleEvent.READY, handler); m.load(); } The code to get it working is really simple: Environment.loadModule("modules.company.dialogs.CreateCompanyWindow", function (e:ModuleEvent):void { // Dialog creation var dialog:* = e.module.factory.create(); PopUpManager.addPopUp(dialog, Environment.getApplication(), true); PopUpManager.centerPopUp(dialog); }, true); In this example, it opens a module based TitleWindow, but there're a lot of other situations, like Canvas based Modules, FormItem based, etc. What's the issue here? If I keep calling this execution (for example click a lot of times in a button), there're different behaviors: 1- It freezes my application 2- It loads the first one and start to open alert messages "SWF is not loadable" (one per click) 3- It never finishes to load the module and fails silently 4- It loads the first one (but not the others), but never removes the progress bar The most reproduceable ones are numbers 2 and 4. Can someone please give me any idea how do I fix this? Thanks in advance, Best regards, -- Guilherme Blanco - Web Developer CBC - Certified Bindows Consultant Cell Phone: +55 (16) 9166-6902 MSN: [EMAIL PROTECTED]<mailto:guilhermeblanco%40hotmail.com> URL: http://blog.bisna.com Rio de Janeiro - RJ/Brazil

