Howto: Flex Module with its own custom RSLs loaded only into child ApplicationDomain?

1k Views Asked by At

I have a complicated application. I use Flex 4.1 RSLs and custom RSLs for all my libraries (and there are like 15 of custom SWCs - Flex Library Project)

I would like to load main application with minimal RSLs needed and then load Flex Module with all other RSLs in the background while users interacts with first part of app.

Main app needs 3 SWCs, Module needs rest of them (12).

If I have one Flash Builder Apllication project with Application.mxml where I have all RSLs linked (as RSLs) and Module.mxml

How do I solve this, so RSLs are loaded with the Module into child application domain?

Currently I am using:

info = ModuleManager.getModule(URL);
info.load(new ApplicationDomain(ApplicationDomain.currentDomain));

... so it should load into new App domain, but RSLs are preloaded into parent domain already!.

I am using static fields/singleton in my Module so I can't load more of them.

If I could load Module with its RSLs into child app domain, Class definitions would separate and I could use two Modules, each with its own static fields.

2

There are 2 best solutions below

1
On BEST ANSWER

Solution came with Flex 4.5 -- Introduction to RSLs

Using placeholder RSLs

When you compile an application with Flex, the default behavior is to compile the application against the framework (or default) RSLs. When the application runs, it loads only the framework RSLs that it actually uses, and creates placeholders for the remaining framework RSLs. When the application loads a module or sub-application that requires one of the framework RSLs for which there is a placeholder, the module or sub-application then loads that RSL into the main application.

see Adobe Flex 4.5 - Introduction to RSLs @ help.adobe.com

1
On

Why not try the OSGI-inspired Potomac modularity framework? It allows you to have much more exact control over the loading of assets. It may involve some refactoring, but the fact that you have 15 different compiled assets in your application suggests that you are already thinking along modular lines.

EDIT:

I should point out that Potomac will load all of the "bundles" into the application domain, but it does solve your issue of loading your assets on demand. I'm not sure which part of your problem is the most important issue. You might also look into sub-applications, which may or may not fit your requirements.