Now I get ReferenceError: Error #1065: Variable MyTesMXMLComponentFromLibrary undefined.
In the library it IS check for export.
So ... ? Is flex crap or what?
Yes, FLEX is crap
Runnin subapplication that loads a RSL doesnt work unless you have the library linked to the main app.
If you don't have mx.core.Application then it sounds like you are trying to link an application with framework.swc set to link type "External".
Only playerglobal.swc should have External linkage in a Flex Project. But you can link other libraries as External in a Library project.
I have a custom library linked as runtime shared library on my mind.
- application A loads (embedds) subapplication B
- Subapplication B is linked to runtime shared library C
But unless I link library C with application A it does not work
How are you loading subapplication B?
I dont have the source codes at hand, but it is like this:
i.e. I dont specify trustContent or loadForCompatibility (for now, I the future I want to load multiversioned applications)
The SWFLoader looks ok. Is the main application loaded from the same domain, http://localhost?
Next I would look at Library C. If you are going to load Library C as an RSL then its dependencies must be loaded before it is. Is Library C linked with any libraries marked as External (excluding playerglobal.swc). If so, those libraries will need to be loaded as RSLs before the RSL for Library C is loaded.
Also look at the debugger output to make sure there are no errors when loading RSLs.
Yes, main application is in the same domain.
The library has no dependencies except the flex framework. Applications and library are currently built using the same SDK version. Library gets loaded, but I get coercion errors saying SomeClass cannot be converted to SomeClassAncestor.
- SomeClass extends SomeClassAncestor
- SomeClassAncestor is in library
- SomeClass is in application B
- Coercion error appears at SomeClassAncestor(SomeClass) - inside application B
1 person found this helpful
If I understand your example AppA loads AppB. AppB loads two RSLs, the framework.swf RSL and libraryC.swf RSL. Is that right? I want able to get a configuration like this to work without any errors.
libraryC is dependent on framework.swf because you compiled libraryC with framework.swc having External linkage. This means you should load framework.swf before library.swf. I think the best way to verify the RSL load order is to compile with "-keep" and look at the compiler generated code for AppB. Look for AppBmx_managagers_SystemManager-generated.as. This file has an info() function. The start of my info function looks like this:
override public function info():Object
From this I can see framework_126.96.36.199.swf is loaded first and CustomFoo.swf is loaded second.
I use "merge into code" for linking the framework (as I suppose it is the least problematic approach) - so framework should be loaded before any RSL linked by the appB. AppB loads just libraryC.
It looks like a problem with ApplicationDomains for me.
All I want is to provide someone (appA) a way to embedd and communicate with my appB that uses my libraryC.
I think this is common business situation when selling someone right to embedd and use your application and it is worth discussing. Thanks for posting!
1 person found this helpful
I've been able to get your simple scenario to work. So far I don't see a problem with Flex loading RSLs. In your scenario there are only two application domains, one for Application A and one for Application B where the second application domain is a child of the second. I don't see a way to get type coercion errors with this simple configuration.
Thanks for checking it. Could you upload your test projects here? What SDKs have you used? I will double check our application on monday when at work. It is possible our problem causes something else...
You are right, it seems to work. Our problem was in the modules. Every module loaded class into its own applicationDomain. Setting the moduleLoader application domain property to the currentDomain helped.
These topics are quite hard to understand as there is not much about them
While your scenario works I did find an issue with loading RSLs. The bug is here https://bugs.adobe.com/jira/browse/SDK-24698. The projects I used are attached to the bug. The issue I found was that sub-applications would load their RSLs into their parent's application domain, if their parent had previously loaded RSLs. If the parent had not loaded RSLs then the RSL would be loaded into the sub-application's application domain as you would expect.