Flex/FlexBuilder:将大型依赖项编译为模块而不是主应用程序

发布于 2024-09-10 09:08:37 字数 659 浏览 2 评论 0原文

我有一个模块 MyModule ,它需要一个大型库:

<mx:Module>
    <mx:Script><![CDATA[
        import com.huge.library.AwesomeThing;
        var myThing:* = new AwesomeThing()
    ]]></mx:Script>
    ...
</mx:Module>

并且该大型库不会从我的主应用程序中引用,除非通过 MyModule

<mx:Application>
    <MyModule />
</mx:Application>

但是当我使用正如我所期望的那样,Flex Builder,com.huge.library 包含在应用程序 swf 中,而不是模块 swf 中。

那么,有什么办法可以欺骗 Flex Builder 将 com.huge.library 放入 MyModule.swf 而不是 MyApp.swf 中?

I've got a module, MyModule which requires a large library:

<mx:Module>
    <mx:Script><![CDATA[
        import com.huge.library.AwesomeThing;
        var myThing:* = new AwesomeThing()
    ]]></mx:Script>
    ...
</mx:Module>

And that large library isn't referenced from my main application, except through MyModule:

<mx:Application>
    <MyModule />
</mx:Application>

But when I build with Flex Builder, com.huge.library is included in the application swf instead of the module swf, as I would expect.

So, is there any way I can trick Flex Builder into putting com.huge.library into MyModule.swf instead of MyApp.swf?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬 2024-09-17 09:08:37

如果您的示例代码是您拉入模块的方式,那么答案是使用 ModuleLoader 而不是在主应用程序中直接引用该模块。您的应用程序应该看起来更像:

<mx:Application>
    <mx:ModuleLoader />
</mx:Application>

并且您应该通过类似于 loadModule("myModule.swf") 的方式加载模块。
祝你好运,
杰里米

The answer, if your example code is how you're pulling in the module, is to use a ModuleLoader and NOT have a direct reference to the module in your main application. Your app should look more like:

<mx:Application>
    <mx:ModuleLoader />
</mx:Application>

and you should load the module by doing similar to loadModule("myModule.swf").
Best of luck,
Jeremy

英雄似剑 2024-09-17 09:08:37

您在主应用程序中有对您的模块的引用吗?有些东西正在将其链接到主应用程序,否则它不会被包含在内。

检查主应用程序中的链接报告,了解依赖项被拉入的位置。

在 FB 3 中,步骤如下。

打开项目

Flex Compiler 选项卡

的属性将 -link-report=true 添加到其他编译器参数中。

构建应用程序。

检查链接报告1.2.3.4.1.1。

根据评论进行编辑。

运行模块的链接报告并将其削减为纯粹要排除的依赖项。

现在,在主应用程序的附加编译器参数中添加以下行

-load-externs=report.xml,

其中 report 是精简后的链接报告。

这将阻止在您的主应用程序中链接依赖项。

Have you got a reference to your module in the main app? Something is linking it to the main app, otherwise it wouldn't be getting included.

Check the link report from your main app to see where the dependency is being pulled in.

In FB 3 the steps are.

Open properties for the project

Flex Compiler tab

Add -link-report=true to the additional compiler arguments.

Build the application.

Check the link report.1.2.3.4.1.1.

Edit from comments.

Run the link report for your module and pare it down to purely the dependencies you want to exclude.

Now add the following line in the additional compiler arguments for your main application

-load-externs=report.xml

where report is the pared down link report.

This will prevent the dependency from being linked in your main application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文