Ok I read it (maybe for 5th time) to recall things a bit. So let me summarize after reading testing etc what I still don't understand:
1) In my application I have 1 custom skin extending Skin.
public var testSkinnn:CSCSkin;
and on creation complete I have:
var testSkin:Class = loaderInfo.applicationDomain.getDefinition("custom.CSCSkin") as Class;
This returns [class CSCSkin].
But the same thing doesn't work in the module because the loaderInfo is null.
So how do you access the applicationDomain of a module ?
2) Looks like I can use almost any component as you say in the siblings and there is no problem, except for the managers classes and Alert. I guess that's because they are singletons with static vars and functions and they register their reference only once - for one application domain and get restrained by it.
I just tried to use Alert only in a module. Application is empty, just a moduleLoader.
private var popUpManager:PopUpManager;
private var alert:Alert;
On creation complete I have:
In the docs it says that registering the singletons/managers in module will make it throw error when you try to use it in a sibling module. But the fact is that the Alert doesn't work at all even in the module I registered them first - it throws error with the PopUpManager. To make the Alert work I had to move the Alert and PopUpManager declarations to the main application. Then they started working everywhere.
Why the Alert is not working if used only in one module?
Oh and I forgot the most important questions I wanted to ask you:
1) How can I cause mismatch of component definitions? Is that even possible within one flex project?
2) I just even tried to have the same component package and name in a merged RSL as in the Flex Project and this didn't cause anything because I was unable to select the component from the RSL, it was like Flex Project one won over the one from the RSL. Is that correct ?
1 person found this helpful
Sorry, must have missed your earlier response.
Use the factory.create("custom.CSCSkin") to create instances of classes in
the module. Then you don't need applicationDomain references.
Hopefully the release notes for Flex 4 say that you have to put singleton
managers in the main app. It wasn't true for Flex 3.
You can cause a mismatch by passing references from one module to another
module via shared singletons or some other mechanism.
First-in-wins. I'm not sure how you set up your RSL test.
Hi, that's for the reply.
Great, I got it for the module part and for the managers.
Could you give me a simple example how to cause that mismatch? I didn't really get it, but if it's hard to do it you can skip that.
I set up my RSL by creating a Flex Library project and a Flex Project. The Flex Library project has package custom with component CustomComponent. Then I add the compiled Library project's swc to the Flex project's library path with merged option. In my Flex project I also had package custom with component named CustomComponent. So I have the same component with the same package in my flex library and in my flex project and I could see only the one in my flex project. When I tested this both CustomComponent were 100% the same. Not sure what would have happened if they had different functions...
<!-- main app -->
public var foo:Object;
<mx:Button click="ml1.url='mod1.swf'" />
<mx:Button click="ml2.url="mod1.swf'" />
<mx:ModuleLoader id="ml1" />
<mx:ModuleLoader id="ml2" />
<!-- module -->
public function runTest():void
if (Application.application.foo == null)
Application.application.foo = new SomeClass();
If you click the first button then the second, you should see a type
Thanks a lot, I've got the idea No more questions here I think