简体   繁体   English

Flex模块与RSL

[英]Flex Modules vs RSL

I'm a little bit confused about when is better to use Flex Modules or RSL libriaries (in Flex 3.5). 关于何时更好地使用Flex模块RSL库 (我在Flex 3.5中),我有点困惑。

My goal is split my project in several unit projects, so I can test and work separately. 我的目标是将我的项目拆分为多个单元项目,因此我可以单独测试和工作。 Let's assume I have a Customer app and Vendor app. 我们假设我有一个客户应用程序和供应商应用程序。 I also have a front-end panel with two buttons. 我还有一个带两个按钮的前端面板。 Each button launches Customer app or Vendor app. 每个按钮都会启动客户应用或供应商应用。

These applications make different things. 这些应用程序有不同的东西 They share some .as functions and common components, too. 它们也共享一些.as功能和通用组件。

I understand that if I make a main project (for user login and to show a first panel) and two modules (customer, vendor) I must have all that components in my Eclipse project, isn't it? 据我所知,如果我创建一个主项目(用于用户登录并显示第一个面板)和两个模块(客户,供应商),我必须在Eclipse项目中拥有所有这些组件,不是吗?

Instead of doing modules, should I create SWC for Vendor and other for Customer app and call from main app by using RSL? 我是应该为供应商创建SWC而不是为客户应用创建SWC而使用RSL从主应用程序调用?

So, which option is more suitable? 那么,哪个选项更合适? What do you advise me? 你有什么建议我的? Which are the trade-offs of each option? 哪个是每种选择的权衡取舍?

On the other side, this flex application is integrated with Java through Blaze and ibatis for persistence managment, and hold by a web apache server. 另一方面,这个flex应用程序通过Blaze和ibatis与Java集成,用于持久管理,并由Web apache服务器保存。 I considered also to create independent war files to keep this indpendence, but I thought this do not optimize flex code. 我还考虑创建独立的war文件以保持这种独立性,但我认为这不会优化flex代码。 I'm right? 我是正确的?

Thank you. 谢谢。

Nil

Modules and RSL's serve different purposes. 模块和RSL用于不同的目的。

RSL's can contain code and assets and are loaded into memory when the main swf loads, as if they were part of the same file. RSL可以包含代码和资产,并在主swf加载时加载到内存中,就好像它们是同一文件的一部分一样。

The main purpose of an RSL is to split out code or assets that might be used in multiple applications , so that the web browser can cache it and only load it once. RSL的主要目的是拆分可能在多个应用程序中使用的代码或资产 ,以便Web浏览器可以缓存它并仅加载一次。 RSL's do not require the Flex framework, and can be used in any Flash/ActionScript project. RSL不需要Flex框架,可以在任何Flash / ActionScript项目中使用。 You don't get any control of how an RSL is loaded, and you can't unload it. 您无法控制RSL的加载方式,也无法卸载它。

Modules are essentially an external SWF that can be loaded on demand, with a lot of Flex-specific code added, to make sure that Flex features work as expected. 模块本质上是一个外部SWF,可以按需加载,添加了大量特定于Flex的代码,以确保Flex功能按预期工作。 For example, style inheritance and embedded fonts can be problematic in loaded SWF's if not handled correctly. 例如,如果处理不正确,样式继承和嵌入字体在加载的SWF中可能会出现问题。 The Flex UI components have specific logic to make sure that these things work properly with Modules. Flex UI组件具有特定的逻辑,以确保这些东西与模块正常工作。 Modules also deal with cross-domain issues (for example you can't normally receive mouse events when the mouse is over a SWF from another domain, but Modules work around this). 模块还处理跨域问题(例如,当鼠标位于来自另一个域的SWF上时,您通常无法接收鼠标事件,但模块可以解决此问题)。

Modules are loaded on demand, and usually contain views. 模块按需加载, 通常包含视图。 The main purpose of a Module is to defer loading a view until it is needed . 模块的主要目的是推迟加载视图,直到需要它为止 That speeds up the initial load of the application, and the user only has to load that view if he actually wants to look at it. 这加速了应用程序的初始加载,并且用户只需要加载该视图,如果他真的想要查看它。

Modules have significant overhead compared to just loading a SWF, but you will need to use a Module to guarantee that all of the features of Flex work as expected. 与仅加载SWF相比,模块具有显着的开销,但您需要使用模块来保证Flex的所有功能都按预期工作。

Both Modules and RSL's can be optimised to remove code that is already included in a specific application. 可以优化模块和RSL,以删除已包含在特定应用程序中的代码。 This makes a lot more sense for Modules though, as it would mostly defeat the main use-case of an RSL by making it only usable with that single application. 这对于模块来说更有意义,因为它通常使得它只能用于单个应用程序,从而使RSL的主要用例失败。

Modules offer finer grained control over when the content is loaded - and optionally - unloaded. 模块提供了更精细的控制内容加载时 - 并且可选 - 卸载。

Assuming the user doesn't have the RSL cached locally, then it is loaded as part of the initial load of the application. 假设用户没有在本地缓存RSL,那么它将作为应用程序初始加载的一部分加载。

Using Modules, you can defer that load until such time as the user requests it. 使用模块,您可以推迟该负载,直到用户请求它为止。

In your instance, it sounds like you want to use a combination of both. 在您的实例中,听起来您想要使用两者的组合。

Declare a module each for the Customer and Vendor applications, and load the appropriate module only on the button click. 为Customer和Vendor应用程序声明每个模块,并仅在单击按钮时加载相应的模块。 This saves you from incurring the download cost of the redundant module. 这样可以避免产生冗余模块的下载成本。

Common logic that is shared between them could go into an RSL, which would be cached on the client side, and only downloaded once. 它们之间共享的通用逻辑可以进入RSL,它将缓存在客户端,并且只下载一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM