views:

41

answers:

1

I am working on a feature for an application that requires Flex 4 functionality. Due to some migration issues of the application from Flex 3.5 to 4.0, I have decided to implement this feature as a module that is compiled with Flex 4.0. The theory is that the application would remain compiled in Flex 3.5 and load the module when it needs it.

Here is the module loading code:

public function loadDiagModule():void {
    var moduleLoader:ModuleLoader = new ModuleLoader();
    moduleLoader.url = "module/DiagrammerModule.swf";
    moduleLoader.loadModule();
    moduleLoader.addEventListener(ModuleEvent.READY, onModuleReady);
}

protected function onModuleReady( moduleEvent:ModuleEvent ):void
{
    var moduleInfo:IModuleInfo = moduleEvent.module;
    var sample:IDiagrammerModule = moduleInfo.factory.create() as IDiagrammerModule;
    Application.application.addChild(sample.testRender());
}

Unfortunately, I am encountering a runtime error when I load the module in the application:

VerifyError: Error #1014: Class mx.modules::ModuleBase could not be found.
 at flash.display::MovieClip/nextFrame()
 at mx.core::FlexModuleFactory/deferredNextFrame()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:631]
 at mx.core::FlexModuleFactory/update()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:401]
 at mx.core::FlexModuleFactory/moduleCompleteHandler()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\FlexModuleFactory.as:718]

I suspect that this may be a result of a mismatch in ModuleBase's class definition in Flex 3.5 and 4.0. Is there some kind of configuration change with my application and/or module project that would remedy this error?

Here's some info on my configuration: IDE: Flash builder 4 plugin

App project

  • SDK: Flex 3.5
  • framework linkage: Merged into code
  • Additional compiler arguments: -locale=en_US,ja_JP -source-path=./locale/{locale}

Module project

  • SDK: Flex 4.0
  • framework linkage: Use SDK default (runtime shared library)
  • Copy non-embedded files to output file: true
  • Generate accessible SWF File: true
  • Additional compiler arguments: -locale en_US
+2  A: 

Loading modules compiled in a different version of the SDK is possible since Flex 3.2, however there are compatibility considerations you must consider.

It's called The Marshall Plan, and you can read more information about it here and hereEssentially the host application establishes different sandboxes for the modules, and communication between them is limited (although still very possible).

Hope that helps.

Marty Pitt
If your main app is compiled with 3.5, then the max version you can use is 3.5. Your version of compiled modules must be equal or less than the compiled version of the main app.
David Collie