I have been tasked with converting a fairly large project from flex 3 to flex 4 to see if we want to upgrade. However, I have run into an issue that has me stumped. We have multiple modules and multiple styles that are loaded at run time. This is flex 4.1.
I tried to put in details because I wasn't sure what was important. I am still fairly new to flex and completely new to flex 4.
The problem is in a call in the main application upon creation complete:
I also tried adding the arguments
styleManager.loadStyleDeclarations(styleSwf, true, false, ApplicationDomain.currentDomain);
In readyHandler in the function loadStyleDeclarations2. The following line of code:
IStyleModule(moduleEvent.module.factory.create()); is returning null. This in turn is due to
var styleModule:IStyleModule = IStyleModule(moduleEvent.module.factory.create());
returning null which in turn is because calling
getDefinitionByName(name:String):Object in FlexModuleFactory with name of "styles" returns null.
The ApplicationDomain 'hasDefinition("styles") is false. Looking at the domain, all it is domainMemory which is null and domainParent which is null so it looks like it has no data at all.
This is where I get stuck. As far as I can tell, this should be the current domain with a loaded style, but isn't.
I have been unable to find any initialization I should be doing, and I would think that the Main Application being complete should be late enough to be initialized.
Does anyone have any idea about what could be wrong?
Here is the stack trace for the assert:
typeError: Error #1009: Cannot access a property or method of a null object reference.
at Function/<anonymous>()[E:\dev\4.x\frameworks\projects\framework\src\mx\styles\StyleManage rImpl.as:1512]
at ModuleInfoProxy/moduleEventHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\modu les\ModuleManager.as:1168]
at ModuleInfo/readyHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\modules\ModuleM anager.as:812]
at mx.core::FlexModuleFactory/update()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\ FlexModuleFactory.as:433]
at mx.core::FlexModuleFactory/docFrameHandler()[E:\dev\4.x\frameworks\projects\framework\src \mx\core\FlexModuleFactory.as:582]
at mx.core::FlexModuleFactory/docFrameListener()[E:\dev\4.x\frameworks\projects\framework\sr c\mx\core\FlexModuleFactory.as:126]
Did you recompile the styles modules with the same SDK version?
Taking your idea, I carefully went through to remove any flex 3 contamination. I did find a reference that was still set to flex 3. & deleted possible old stuff.
This did fix the issue, so thanks for the help. It sent me down the right path.