Flex Runtime Loaded Module issue

Answered

Hi,

I'm working on a flex desktop AIR project composed of several librairies and RLM.

Each RLM is added as a "build configuration" in the main application dependencies tab. 

In the main application, I need to reference a class contained in one of the project RLM but I'm not able to import this class. I don't understand why ?

Can anyone help me ?

Thank you in advance.

Vincent.

0
18 comments

Use Flash Build Configurations for managing dependencies for modules. See Configuring dependencies for modular applications specifically.

 

0
Avatar
Permanently deleted user

Hi Andrey,

Thank you for your answer. I already read this section about dependencies configuration. In my case I chose the second option : Specifying the dependencies by listing the RLM build configurations

So in my project main application module, each RLM module  is added in the dependencies tab with the  "add a build configuration" button and listed with the "Loaded" linkage type.

I'm able to load a RLM but my problem is that I cannot reference (i.e. import) any class contained in those RLM's from a main module class. 

Can you help me about that please ?

Thank you in advance.

Vincent.

 

0

Can you provide a sample project to check? For uploading you can use ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com (files are accessible by developers team only) or any file sharing service.

0
Avatar
Permanently deleted user

Hi Andrey,

I just upload a project zip named

vj_test.zip 

It's a minimalistic project that contains only one runtime loaded module (RLM). This module is added to the main application dependencies with the "add build configuration" and appears in the dependencies tab with the "loaded" linkage type.

My problem is that I cannot reference any class from this module from main.mxml

Thank you in advance.

Vincent.

 

0

You should add a dependency on myModule for the lab module, not the vise versa:

0
Avatar
Permanently deleted user

Hi Andrew,

Thank you for your answer but it doesn't work.
Sorry, my description of the problem was probably not clear enough but it will be much simpler with your screen capture :

In main.mxlm, I want to be able to reference the MyClass class located in the myModule module. 

Your screen capture shows that myModule is a simple library (lib) that will be merged in the main application code.

On my project myModule is a RLM (runtime loaded module) not a simple library.

Thank you 
Vincent

0

Sorry for delayed reply. Why do you need to use RLM configuration?

You should define the myModule build configuration of a type Library:

and then you can use it as a Build Configuration dependency for the lab module.

0
Avatar
Permanently deleted user

Hi Andrey,

No worries for the delay, it's Christmas time for everyone :-)
Regarding the use of RLM, the application I'm working on was, until now, developed with Adobe Flash Builder using a lot of Flex modules. So I try to reproduce as far as possible the project organization. 

I understand the solution you propose but this is not what I want to do. What I don't understand is why I cannot reference the code of a RLM dependency while I can if it's a "regular" library. Is it a bug of Intellij or is it by design ?

Thank you.

Vincent. 

0

Vincent, thank you for the sample project. If I add 

var a:MyClass;

to the Main.mxml file then I get a compiler error

Error:(6, 0) [lab]: Error code: 1046: Type was not found or was not a compile-time constant: MyClass.

So it looks like the IDE is right that it shows MyClass as red. As far as I understand you can't directly use classes from RLM right in the main application. Am I missing something?

0
Avatar
Permanently deleted user

Hi Alexander,

Like a said in my previous post, this project has been developed using Adobe flash builder. In flash builder, any class of a runtime loaded module can be referenced in the main application. It's the developer's responsibility to ensure that a specific module is loaded before accessing it's content a runtime.

In my case I have 18 runtime loaded modules that are completely encapsulated (the main app simply load them on demand) except for one module UI class that needs to be referenced in the main application. 

So I don't know what should be the correct IDE behavior in this particular case but I'm noticing that Intellij and Flash Builder do not behave the same way.

I did however find a solution with Intellij : in the dependencies tab of the main application module, I clicked the add button -> new library and selected the src folder of the RLM in the files browser, clicked open, and then choose the "Raw ActionScript library" option in the next window.

Not sure this is a very conventional workaround but it works :-)

But my question remains : is it deliberate not to have access to a RLM content from the main application module when it's added as a build configuration ?

Thank you.

Vincent.

 

0

IDE doesn't provide code completion and reference resolution for classes from other modules if Application BC (aka build configuration) depends on RLM BC with 'Loaded' linkage type.

The reason: it doesn't compile. IDE wants to show uncompilable code red. If the code compiles but IDE shows it red then it's probably a Flex plugin bug.

How do you compile your project? Looks like you are not using IDE for that, right?

I can suggest one more workaround for you. In MyModule create one more build configuration with Output Type: Library, check 'Skip compilation (use build configuration for code highlighting only)' checkbox. Add dependency on this library in you main app run configuration. This workaround is safer than the one with the Raw AS Library.

0
Avatar
Permanently deleted user

Alexander,

Thank you for your explanation.

Regarding your workaround, I'm facing an issue : If I check the skip compilation checkbox, the library is not generated and the compiler throw an error telling me that it is unable to open the corresponding .swc file. 

Am I missing something ?

Thank you.

Vincent.

0

I assumed that you don't use IDE for compilation. Because IDE can't compile the main app if it references classes from RLM (and that's why IDE highlights them red).

The trick with Raw AS Library means that all the referenced classes from the RLM will be included in the main_app.swf. If it's ok for you then it's pretty much the same as depending on other BC as library and not checking 'Skip compilation'. But does it make sense to include the same classes both in the main_app.swf and RLM.swf?

0
Avatar
Permanently deleted user

Alexander,

The compilation is done by Intellij.
I'm not sure to understand correctly your workaround : I do need to generate a .swc library based on the RLM source for it to work, correct ? 

Vincent.

0

Let's return to the original question. As far as I understand:

  • you want to have main_app.swf and RLM.swf. You don't want main_app.swf to contain classes that are included in RLM.swf
  • in main_app source code you want to reference classes from RLM source code

In my understanding, it's not possible to compile such application. Compiler doesn't see RLM source code when it is compiling main_app source code.

To use classes from RLM source code in main_app source code you can configure a .swc library based on the RLM source and configure main_app on this library dependency. In this case you'll have green code, successful compilation, but referenced classes from RLM sources will be compiled right into main_app.swf.

0
Avatar
Permanently deleted user

Alexander,

Ok, that's what I understood :-)

So there's no differences between the 2 workarounds : in both cases, referenced classes from RLM will be compiled into the main application swf ?

Vincent.

0

Yes, in both cases, referenced classes from RLM will be compiled into the main application swf.

I think swc library is a more natural way of doing things. In case of a raw AS library, I suspect, IDE may decide to skip main app compilation if only RLM souces have been touched since the previous compilation (IDE will think that nothing changed since the previous compilation).

0
Avatar
Permanently deleted user

Ok that makes sense, so I will choose the .swc way.

Thank you to both of you and Andrey for your time.

Vincent.

0

Please sign in to leave a comment.