Flex 的模块化

发布于 2024-09-02 22:47:53 字数 559 浏览 7 评论 0原文

我正在开发一个相当大的 Flex/Air 应用程序。我们使用 GraniteDS 和 Tide 与 Java EE 服务器中的模型进行交互。

我一直在阅读有关 Flex 中的模块化和模块的内容。该应用程序已经构建完毕,我正在想办法重新设计一些类和部分。从我到目前为止所读到的内容来看,我知道模块是一个不同的 swf,可以动态加载。大多数教程/文档都是面向使用 Flex 或 Air 的 Flash“程序员”而不是真正的开发人员,因此这使得在线资源更难获得。

我还不明白的是如何在这个模块下封装 ActionScript 类或 MXML 视图。

我已将一些代码分离到库中。例如,从 Granite 生成的代码位于“服务器”库中。但我想将逻辑部分与其主持人、控制器和视图分开。模块是出路吗?是否有“傻瓜模块”或“程序员入门 Flex 模块”之类的教程,以便获得更好的视角来构建我的架构?何时选择库以及何时选择模块?

我正在使用 Flex 3.5,迁移到 Flex 4 还很遥远,所以请不要回答 Flex 4,谢谢!

I'm working on a pretty big application for Flex/Air. We are using GraniteDS and Tide to interact with the model from our Java EE server.

I've been reading about modularization and Modules in Flex. The application has already been built, and I'm figuring a way out to re-design some classes and parts. From what I've read so far, I understand a Module is a different swf which can be dynamically load. Most of the tutorials/documentation are oriented to Flash "programmers" who are using Flex or Air instead of real developers, so that makes online resources harder to get.

What I can't understand - yet - is how to encapsulate ActionScript classes or MXML views under this module.

I've separated some of the code into libraries. For example, the generated code from Granite is in a "server" library. But I would like to separate parts of the logic with its Moderators, Controllers and Views. Are modules the way to go? Is there a "modules for dummies" or "head first Flex Modules for programmers" like tutorial in order to get a better perspective in order to build my architecture? When to choose libraries and when to choose modules?

I'm using Flex 3.5, and a migration to Flex 4 is way far into the future, so no Flex 4 answers please, thanks!

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

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

发布评论

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

评论(1

神爱温柔 2024-09-09 22:47:53

模块是将 UI 封装到彼此不依赖的不同部分的答案。将它们视为应用程序内的应用程序。

如果您想封装“代码”,即非 ui 动作脚本,那么您实际上只需要类和类包。您还可以将该代码打包到 SWC 中,这只是该代码的编译版本,您可以将其包含在多个项目中(我认为这就是您所说的库的意思)。

您不会想创建一个仅包含非 ui 代码的模块。您不想使用模块来分离应用程序中的模型/视图/控制器。

如果您的应用程序的一部分,在大多数情况下完全独立运行,除了传入的一点信息之外,与应用程序的其余部分没有真正的依赖关系,那么这对于模块来说是有意义的。

我们使用模块的地方主要是针对具有不同部分的应用程序,您一次只能在一个部分中工作。其他部分不需要占用资源,因此我们在模块中拥有不同的部分,并根据需要加载/卸载它们。

这有帮助吗?

编辑回复以下评论:

我所说的库是指 Flex 库
项目,您封装的地方
类并使用 SWC。你能有
Flex 项目中的这些库?
(我使用一个单独的图书馆项目
每个新库)。

是的,您可以在 Flex 项目中使用这些 swc(代码库)。只需将 SWC 放入 Flex/Flash 构建器项目的 lib 目录中,代码就会自动添加到您的类路径中。只需确保单个 SWC 内的代码所需的所有内容都位于该 SWC 内。不要让一个 SWC 依赖另一个 SWC 来运行。

Modules are the answer for encapsulating UI into different sections that do not depend on each other. Think of them like applications inside of applications.

If you want to encapsulate "code", meaning non-ui actionscript, then you really just want classes and packages of classes. You could also package that code into a swc, which is just a compiled version of that code that you can include in multiple projects (I think this is what you meant by libraries).

You wouldn't want to create a module just to contain non-ui code. You wouldn't want to use modules for separating out the model/view/controller in your application.

If you have part of your application, that for the most part runs completely on its own, with no real dependencies on the rest of the application except for maybe a little bit of information passed in, then it makes sense for modules.

Where we use modules mostly is for an application that has different sections to it where you are only working in one section at a time. There is no need for the other sections to be taking up resources, so we have the different sections in modules and load/unload them as necessary.

Does that help?

Edit in reply to the comment below:

By libraries I meant Flex Library
Projects, where you encapsulate
classses and use the swc. Can you have
these libraries inside a Flex Project?
(I use a separate Library Project for
each new library).

Yes, you can use these swc's (Libraries of code) inside of your flex projects. Just drop the swc in the lib directory in your flex/flash builder project and the code is automatically added to your classpath. Just make sure that everything that the code inside a single swc needs is inside that swc. Don't make a swc rely on another swc to function.

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