So I ported my project from Flex 3 to Flex 4. I'm trying to simply load a module in an application and setup its mediator to use it. I keep getting this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.core::UIComponent/getStyle()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:10372]
at spark.components::Label/createTextLinesFromTextBlock()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\Label.as:831]
at spark.components::Label/createTextLines()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\Label.as:808]
at spark.components::Label/http://www.adobe.com/2006/flex/mx/internal::composeTextLines()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\Label.as:474]
at spark.components.supportClasses::TextBase/measure()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\components\supportClasses\TextBase.as:533]
at mx.core::UIComponent/measureSizes()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8042]
at mx.core::UIComponent/validateSize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:7966]
at mx.managers::LayoutManager/validateSize()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:617]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:709]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
I was reading on the adobe forum about this and they said in response to someones similar issue:
[http://forums.adobe.com/message/2792526#2792526]
The main point of modules is to make the main application SWF smaller. When using modules you have to realize that any mention of a class in the application code links in those classes and all dependent classes. We sort of assumed that folks knew that and have made changes to the styles system in Flex 4 that require that you know that.
And again, in reference to someones specific problem:
You are using the module class in the main app which sort of defeats the point of having a module as it will link testModule into the main app. When that happens in Flex 4, the styles don't get set up properly. You should use an interface instead of the module class.
The basic idea I gather is that you cant reference the module view component in any other code. Which brings me to a lot of problems and two questions:
1. Is that true?
2. If it is, how do I strongly type the view component in the mediator? Do I have to write an interface for every module?