Upgrading the SDK and Developing for Flash Player 10 in Flex Builder 3 May 28, 2010Posted by Tournas Dimitrios in Flex.
As a Flex developer, keeping up with new advances in Flash Player 10 is essential. Thus, it’s nice to be able to build to the latest Flash Player, without waiting for the next major release of Flex Builder. This article will show you how to get Flex Builder 3’s code assist to recognize Flash Player 10 classes, and to compile for and check for the presence of the Flash 10 Player, without a lot of mucking about with configuration files.
The Problem of Upgrading Flex 3
When the Flash Player 10 beta was out, upgrading Flex Builder to be able to compile to the beta 10 player could be done, but it was a complex process not for the faint of heart. It required the manipulation of Flex Builder configuration files and the downloading of the Gumbo (Flex 4 alpha) SDK to grab a copy of the AS3/Flash API framework file that the compiler required.
The release of Flash Player 10, and the Flex 3.0.2 nightly build, gave developers more reason to start building to Flash 10, and documentation on opensource.adobe.com made this process a little less mysterious. But, manipulating Flex Builder’s configuration files set Flash Player 10 as the default for all Flex projects. What if you want to compile some projects to Flash 9*, and some projects to Flash 10?
* since the browser penetration is around 97% as of this writing May 2010.
The release of the Flex SDK stable build version 22.214.171.12494 on October 23rd made this process much easier. It is an SDK version that’s considered stable, and the framework folder structure not only allows for different player versions (which was introduced around SDK v.3.0.2), it also includes the Flash Player 10 playerglobal.swc file, so you don’t need to grab it from the Gumbo SDK build.
In this tutorial, you’ll see how you can configure Flex Builder 3 to compile for Flash Player 10 using a v.3.5a build of the Flex SDK, without needing to modify any configuration files.
Step 1: Visit http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+3 and downloaded file any build greater than 126.96.36.1992 dated . This example will demostrate how to install build 3.5a December-2009 ( Latest Milestone Release Builds)
Step 2: Unzip the download and add it to the sdks folder of your Flex Builder install. In my case this is within C:\Program Files\Adobe\Flex Builder 3\sdks.
Step 3: Now open the Flex Builder preferences (Windows –> preferences) and expand the menu to flex -> Installed Flex SDKs. Click the add button.
Step 4:Navigate to the new SDK that you just installed in step 2, give it a unique name and click OK.You might want to customize the Flex SDK name so that it gives you a little more information than simply “Flex 3.2”, like perhaps “Flex 3.5 (stable)”.
Step 5: You can now set this new SDK as your default SDK and click OK Now that you’ve installed the new SDK, you need to create a Flex project which will make use of the Flash Player 10 swc for this project.
Step 6: Create a new Flex Project
Step 7: Create the project as type Web Application
Step 8: Right click on the new project and select Properties. Navigate to Flex Compiler. Make sure either you have the new 3.5a as the default SDK or if you didn’t set it as the default in Step 5, make sure that you choose Use a specific SDK and set it to 3.5a. Also, change the flash player version required to 10.0.0.
Step 9: Switch to Flex Build Path, expand the 188.8.131.529 library and remove the playerglobal.sdk
Step 10: Click on Add SWC
Step 11:Navigate to the new SDK installed in Step 2 to frameworks/libs/player/10/playerglobal.swc and click OK
Step 12: Expand the new playerglobal.swc and double click on Link Type. Change it to External.
Step 13: Now you should see External next to the link type entry. This tells the Flex compiler to refer to a playerglobal.swc which is not in the default location indicated in the configuration files, so you won’t get an error when attempting to compile.
Step 14: Next you need to tell the version detection in the wrapper to look for Flash player 10.Still in the Properties window, select ActionScript Compiler.Change the Required Flash Player version setting to 10.0.12, which is the current version of the Flash Player.
Step 15:Now we’ll try out the code assist in Flex Builder to see if our changes have taken.
- Open up an MXML or ActionScript file in the Editor in Source Mode.
- Type an import statement involving one of the Flash Player 10 classes, such as flash.display.Shader.
You will now find that Flex Builder compiles with the ability to use the Flash Player 10 classes, and the version detection will look for Flash Player 10.
Some people have reported that Flash 10 version detection causes problems some detection schemes use string comparisons instead of numbers, causing the computation to regard version “10” after version “1”, not after 9. If this happens with you, it is recommended you use SWFObject v.2.0 for your project, which resolves this issue. The implementation of custom HTML templates in Flex Builder 3 is outside the scope of this article. For more information consult the SWFObject web site.
Is it easier to change settings in Flex Builder instead of configuration files? Certainly. Is it the best way? Not necessarily. The disadvantage of this technique is that you have import your SDKs into each new workspace, which can be mitigated by exporting your Flex Builder preferences and importing them into another workspace. But you’re still left with having to do the playerglobal.swc switch with each project, which can get tiresome if you find you’re compiling to Flash Player 10 a lot. So if you find you will be compiling to Flash Player 10 most of the time, go through the configuration file setup outlined in the documentation on opensource.adobe.com.