Tuesday, March 16, 2010

Modules loading modules?

I guess this is not something that you come across often everyday. But if you have an application that you are trying to modularizes into many levels you are likely to hit the Security sandbox. I started to split up the Application into three separate levels. So I had an Application that would load a Module(s) that would then load Module(s). I was using the standard mx.modules.ModuleLoader to load each of the Modules. All seemed great as the application started and the modules where loading and running but something was missing... the data. I then found a series of strange type errors where Object of ClassA does not match ClassA@33455. Initially this threw me because it is the same class but this is because they are coming from different domains. The second level of ModuleLoaders were not picking up the correct ApplicationDomain but ending up in another domain.

Simple fix for this is set the ModuleLoader.applicationDomain = ApplicationDomain.currentDomain

I know most Flex applications would not spilt themselves up so granular but it has been an interesting experience.

No comments: