the blog
Back to -Blog

Flex 3 Compatibility in Flex 4 Applications

The secret is the Compatibility Mode
by Huw Collingbourne
Saturday 12 June 2010.

I’ve just been converting some old Flex 3 projects to run with the Flex 4 SDK.

Mostly this is pretty simple to do. I use the Amethyst Conversion and Importer Wizard, select ‘Convert project in original location’, and, in the configuration page, select the Flex 4 option. The Wizard creates a new project from all the original source files and it adds the appropriate Flex 4 libraries to the ‘References’ node of the Solution Explorer.

Flex 4 has its own ‘Spark’ controls which, in many cases, are alternatives to the MX controls of Flex 3 - but you are not obliged to use these. You may even continue to use an mx:Application as the main container of your user interface defined in MXML (instead of Spark’s s:Application) and the program will still compile and run.

But there are exceptions to that rule. I found that when certain MX-specific attributes are included in the MXML tags, the compiler complains. One of my converted Flex 3 applications, for example, has styles such as backgroundGradientColors and dropShadowEnabled set on the Application and components. When I tried to compile this, the following messages appeared in the Amethyst Error List and the compiler refused to build my project.

I could, of course, decide to rewrite the use interface using all Spark components. But that isn’t really necessary. The simple solution is to compile using Flex 3 Compatibility mode. To do this, go to the Project/Properties/Compiler page and check off this item...

Rebuild and run. Now, even though I’ve built using the Flex 4 SDK, my application looks and works like a Flex 3 program and my Flex 3 styles no longer cause any problem.

Bookmark and Share   Keywords:  Amethyst  Flex
© SapphireSteel Software 2014