Loading flex modules compiled with Flex 4 SDK into

2019-02-26 10:27发布

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

1条回答
smile是对你的礼貌
2楼-- · 2019-02-26 11:16

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.

查看更多
登录 后发表回答