flashapache-flexactionscript-3rslapplicationdomain

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


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.


Solution

  • 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