3
votes

I'm a little bit confused about when is better to use Flex Modules or RSL libriaries (in 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.

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?

Instead of doing modules, should I create SWC for Vendor and other for Customer app and call from main app by using 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. I considered also to create independent war files to keep this indpendence, but I thought this do not optimize flex code. I'm right?

Thank you.

Nil

2

2 Answers

3
votes

Modules and RSL's serve different purposes.

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.

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's do not require the Flex framework, and can be used in any Flash/ActionScript project. You don't get any control of how an RSL is loaded, and you can't unload it.

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. For example, style inheritance and embedded fonts can be problematic in loaded SWF's if not handled correctly. The Flex UI components have specific logic to make sure that these things work properly with Modules. 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).

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.

Both Modules and RSL's can be optimised to remove code that is already included in a specific application. 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.

2
votes

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.

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. 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.