4 Replies Latest reply on Feb 28, 2011 2:00 AM by Anirudh Sasikumar

    Cross-compilation for Flash Player 9 and 10

    Sander Kruger

      Using Flash Builder 3 with the SDK version 3.5, I developed a codebase that can be compiled for both Flash Player 9 and Flash Player 10. By using conditional compilation, I'm able to enclose parts that are only supported by Flash Player 10 in conditional blocks that only compile for my v10-targeted swf's and have alternative parts for my v9-targeted swf's.


      My HTML wrapper then selects the SWF based on the user's player version.


      I'd like to migrate to Flex 4, but Flex 4 only targets Flash Player 10 and up. My dilemma is this: how can I keep a relatively coherent codebase, while supporting both a version that can run in Flash Player 9 AND take advantage of new features for users with Flash Player 10 and up?


      Basically, it boils down to this: how can I minimize the conditional block in my code, while keeping a single codebase that, based on compiler options, can either compile for Flex SDK 3.5 (targeting Flash Player 9) or compile for Flex SDK 4? And keep readable code, of course.


      It seems that the first hurdle to take is namespaces. For Flex 4, the namespace declarations in the header of each MXML file change. Is there any way to declare namespaces in config files or declare variables in the config file that can be used in namespace declarations?


      Then, I notice that in Flex 4 a number of classes moved from the mx namespace to the fx namespace. I suppose it would be possible to declare a new namespace (say mfx) that either points to the old Flex 3.5 mx namespace or to the new Flex 4 fx namespace, and use mfx to qualify these classes in the code. Of couse, this requires conditional namespaces.


      Does anyone have experience with migrating to Flex 4 while keeping backward compatibility with Flash Player 9?