Migrating Flex 3.x application to Flex 4.5 – Tip No. 1

I am currently doing some migration work for a client, migrating their Flex 3.5 application to Flex 4.5.

 

Occasionally, I will undoubtedly encounter bumpers…
This will be an account of those bumpers, and how I came to resolve them. This is not guaranteed to be the best solution, just the one that worked for me, usual caveats apply.

 

The application I am migrating is built of modules, and every time I ran the app I got an exception on UIComponent’s getStyle method. Nothing I did fixed this, until I found this link.

It describes a compiler flag, namely ‘isolate-styles’ which, when set to false, you can prevent merging of styles between the modules and the main application.

 

“To prevent style merges, set theisolate-stylescompiler argument tofalse. By doing this, you might trigger type coercion errors when loading skins. Modules also might not be properly garbage collected when they are unloaded. This is because the main application’s StyleManager will maintain references to the module even after is is unloaded. When you setisolate-styestofalse, if more than one module loads a style, the first one loaded wins. In this case, styles set on modules can be overridden by those set on other modules.”