Flex 3 to Flex 4 Migration

While migrating Flex 3 (SDK 3.4) based project to Flex 4 (SDK 4.5 – Hero), I came across an issue “Cannot access properties of null object” (I don’t remember the exact error message, but it is somewhat similar). After running the application in debug mode, we found that a variable “_nonInheritingStyle” [array] declared in UIComponent is null and ActionScript tried to retrieve value from it. At first instance we thought that the problem could be related to the way stylesheet is loaded and hence instead of loading stylesheet dynamically, we added mx:style tag to the Application. But the problem remained as it is.

The next thought was to find out a solution on internet and specific steps to be followed for migration of Flex 3 project to Flex 4. We came across an article from Adobe which has detailed explaination for steps to be followed for various scenarios. Though we followed all the steps mentioned in the Article, we continued to experience the same error.

The next step was to put various breakpoints into internal code of framework and findout what is really causing an issue. Finally we found that the problem was specifically occurring when we tried to load a module into Moduleloader (We are having custom moduleloader). After digging more, we found that the StyleManager instance assigned to the newly loaded module factory was differing from the Application and one of its inherited property stylesRoot is having value as null.

Now we found out the problem, the next step was to put an appropriate fix. But I didn’t found any solution for this and hence I applied following code at the module load to make it working.

var b:IStyleManager2 = StyleManager.getStyleManager(IFlexModule(a).moduleFactory); //a is instance of the module loaded
b.stylesRoot = styleManager.stylesRoot;

Above script must immediately be called once module is loaded.

Though this resolved the problem and application started working, we didnt find any reason for such a behavior. Hence not sure if this is an appropriate fix. Note that the source code we were trying to migrate was written using SDK 3.4 and we didnt check the SDK compatibility checkbox available in Flash Builder 4. There is no error reported if this checkbox is turned on, but we were more interested in leaving it unchecked.

By Carbon Rider

Hi this is Yogesh, welcome to my world. Being passionate about learning new technologies and building frameworks, I end up spending most of my time in front of computer. But over last few months, I realised apart from being good coder and designer (Yes I am) I have something hidden in me. And thats called ART.

4 replies on “Flex 3 to Flex 4 Migration”

Hi , thx a lot for the post.
I’ve been looking all over the net for 3 Days, having this error with no reason on all my modules.
I still haven’t tried using Flash 10.2 (still beta), it seems there are news modules with spark. Don’t know if it is fixed in it, but anyway I’m working with your solution. Thanks again


I have migrated my application from Flex 3 to Flex 4. My application has 3 different modules. The modules are not loading when I run my application with Flex 4. I am not getting any error either. Can you help me in this respect.

Nirmal Kumar Bhogadi

Leave a Reply