Copy link to clipboard
Copied
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?
Regards,
Copy link to clipboard
Copied
This appears to be a Flex question. Please try the Flex forums here for better response http://forums.adobe.com/community/flex/flex_general_discussion
Copy link to clipboard
Copied
Thank you for your suggestions. But isn't conditional compilation a flash builder feature, rather than a flex feature?
Copy link to clipboard
Copied
The actual flex compiler resides in the Flex SDK. Flash Builder makes API calls into the SDK to compile.
Copy link to clipboard
Copied
Keeping compatibility for both SDK 3.5 and SDK 4 in the same code-base can be quite challenging given the fact that Flex 4 has syntactic changes in MXML and CSS.
My suggestion would be to separate them and treat them differently. Keep pieces that do not rely on framework specific features in a common library.
P.S: As Gurdeep suggested, you'll get better answers for this on the flex general discussions forum.
Cheers,
Anirudh