Loading flex modules compiled with Flex 4 SDK into an application compiled with Flex 3.5

旧时模样 提交于 2019-12-20 03:38:15

问题


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:


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.



来源:https://stackoverflow.com/questions/4056686/loading-flex-modules-compiled-with-flex-4-sdk-into-an-application-compiled-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!