By some sort of Murphy's law and I got it working right after I posted this. I don't know why it is working now and not before though.
I'm suspicious of flex builder's module compilations and of IE's caching mechanisms, but alas, I have no proof. --- In [email protected], "kallebertell" <[EMAIL PROTECTED]> wrote: > > After trying to refactor some the views of our application into > modules (and failing miserably) I'm finally frustrated enough to post > a cry for help here and see if someone could kindly offer me a clue. > > I have a module (extends ModuleBase) which implements my IViewModule > interface, which is a shared definition between the main application > and the module. > > The loading is done like this: > > function loadModule() : void { > var info : IModuleInfo = ModuleManager.getModule("module.swf"); > info.addEventListener(ModuleEvent.READY, moduleReadyHandler); > info.addEventListener(ModuleEvent.ERROR, moduleErrorHandler); > info.load(); > } > > function moduleReadyHandler(event:ModuleEvent) : void { > var module : IViewModule = > event.module.factory.create() as IViewModule; > > if (module == null) > throw new Error("I'm null, therefore I ain't"); > } > > I created a test module with some of it's own unique classes and this > worked fine. Swell, I thought, and commenced refactoring a view of > ours into a module and removed any reference to its main class from > the base application. > > Loading the module seems to work fine, but the call to > factory.create() just returns null. > > If I add references to the view's main class into the base application > so the class definitions are included in the base application the > create() call returns a proper instance, but that goes against the > whole point of modules. > > I've tried playing around with application domains and module > optimizations but I reckon they aren't the problem. I'm probably > missing something vital but I have no clue what it could be. > > Which finally leads me to my question: > > What are the most common mistakes which would cause this? >

