In case anyone comes upon this extremely obscure problem, let my hours of sorrow guide you towards blessed relief.
I was working with a very complicated Flex project that I have been working on since Flex Builder 3, still located in its original FB3 location, "C:\Documents and Settings\[myName]\My Documents\Flex Builder 3\[ProjectName]. When I installed Flash Builder 4.6, I imported this project using "File > Import Flash Builder Project ...", using 4.6.0 library path, 4.6.0 compiler, pretty much everything except the project folder itself was using the new linked resources, paths, etc.
And all had been going well for a long time ... until today.
For some reason when I added an s:FormItem to one of the components the following error would show up:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spark.utils::FTETextUtil$/getEmbeddedFontContext()[E:\dev\4.y\framewo rks\projects\spark\src\spark\utils\FTETextUtil.as:207]
at spark.utils::FTETextUtil$/calculateFontBaseline()[E:\dev\4.y\framewor ks\projects\spark\src\spark\utils\FTETextUtil.as:136]
at spark.components.supportClasses::GroupBase/get baselinePosition()[E:\dev\4.y\frameworks\projects\spark\src\spark\com ponents\supportClasses\GroupBase.as:388]
at spark.components::Group/get baselinePosition()[E:\dev\4.y\frameworks\projects\spark\src\spark\com ponents\Group.as:284]
at spark.layouts::ConstraintLayout/parseElementConstraints()[E:\dev\4.y\ frameworks\projects\spark\src\spark\layouts\ConstraintLayout.as:1818]
at spark.layouts::ConstraintLayout/parseConstraints()[E:\dev\4.y\framewo rks\projects\spark\src\spark\layouts\ConstraintLayout.as:1632]
at spark.layouts::ConstraintLayout/measure()[E:\dev\4.y\frameworks\proje cts\spark\src\spark\layouts\ConstraintLayout.as:414]
at spark.components.supportClasses::GroupBase/measure()[E:\dev\4.y\frame works\projects\spark\src\spark\components\supportClasses\GroupBase.as: 1148]
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::measureSizes()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as :8506]
at mx.core::UIComponent/validateSize()[E:\dev\4.y\frameworks\projects\fr amework\src\mx\core\UIComponent.as:8430]
at spark.components::Group/validateSize()[E:\dev\4.y\frameworks\projects \spark\src\spark\components\Group.as:1012]
at mx.managers::LayoutManager/validateSize()[E:\dev\4.y\frameworks\proje cts\framework\src\mx\managers\LayoutManager.as:665]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\framewo rks\projects\framework\src\mx\managers\LayoutManager.as:792]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y \frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]
pointing me to line 207 of FTETextUtil.as:
206. fontContext = embeddedFontRegistry.getAssociatedModuleFactory(
207. font, bold, italic, client, moduleFactory, localLookup, true);
Rather odd error for adding a simple tag. I figured there was some sort of conflict somewhere in the component stack. So I go through each component, one by one, hour upon hour of testing, eliminating block after block of code, component after component, class after class, scripts, stylesheets, namespace declarations, damned near everything ... until I finally get to this:
<?xml version="1.0" encoding="utf-8"?>
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
And it's still erroring the exact same way. (Yes, I tried it in a Form, too, no difference.) Now obviously something is quite wrong at this stage. When all you have is the application and one simple tag with no properties and it's still erroring, something is seriously fubar.
So I test s:FormItem in new projects, created outside of the FB3 location. Everything works. (One would hope!) Then I created a new Application, cut-and-pasted all of my old App code into the new Application, copied over all of the files into duplicate files in the new folder location - everything works fine. I have looked at all the properties of the two projects (build path, compilers, etc) and I can't spot a single difference other than the project folder location, "Properties > Resources > Linked Resources > Path Variables > PROJECT_LOC" ... and yet ...
Bottom line, in case anyone has this obscure issue, and finds this post, this is your answer. For some reason imported older projects trigger this error with FormItem and its null object problems with getAssociatedModuleFactory. Start a new project, move your components, class files, etc, into the new folder, and all will work once again as it should.
What a colossally weird and time-consuming PITA.
Good one. Even I faced the same issue some time ago while importing flex 3project into Flash Builder 4.5.1.
I did the same as you've done, after wasting frustrating hours on it.
Hope this will help a lot of people out there.
I faced the same bug when we changed SDK of our project to new.
I found a way to avoid the exception.
I detected that if I change fontLookup in CSS of my project from "auto" to "device" all will work correctly.
Europe, Middle East and Africa