Working with Flex 2 on Mac OS X

3 minute read Published:

(Note: this post was originally written on release of the Flex 2 alpha. I’ve since updated it for the Flex 2 beta.)

Macromedia recently announced Macromedia Labs and the availability of the Flex 2 product line alpha, which includes a new Eclipse-based IDE and a new high performance client runtime (Flash Player 8.5) alongside the development framework. Unfortunately, for now, development on the Mac is not supported and Macromedia only provide an installer for Flex Builder 2, the Flex Framework 2, Flex samples and command line tools for Windows.

So I set about trying to discover, if as with the 1.0 release, I could get the framework at least to run on OS X: and the short answer is yes, it’s relatively simple.

First of all you need to extract both the framework and the player from the Download for Windows. To do this, just unzip the relevant components from the .exe file. Assuming you’ve already downloaded FlexBuilder2_Beta1_Install.exe to your desktop, this script does exactly this and then copies the ‘frameworks’ and ‘lib’ directories to a flex2 directory in /Library and the Install Flash Player 8.5 OSX.dmg to your desktop. (Or you can obviously just run the installer on Windows and copy across the relevant files.)

Once you’ve got the framework installed, you can use mxmlc – the (Java) Macromedia Flex Compiler – from the command line or better still with Ant. Here’s a version of the ‘Hello World’ example Flex project from Macromedia’s Quick-start tutorials book with the simplest possible Ant build file: just download and run ‘ant’ (defaults to the ‘build’ task) in the Quickstart directory, and – assuming you’ve already installed the player – then open QuickStart.html. You should see the movie initialise and the words “Welcome to Flex” appear.

(I had no luck at all getting the IDE work, I did try extracting Flex Builder 2′s ‘features’ and ‘plugins’ directories and copying the contents of these to my Eclipse installation. Although I was then able to create a new Flex project, I wasn’t able to start the MXML editor which failed with a NullPointerException.)

Update: in case you missed the original Flex 2 announcement and were wondering why you’d bother investing any time in an expensive enterprise-only technology, Macromedia also announced a new (very welcome) licensing model for Flex:

“Macromedia is also introducing a new tiered licensing model to bring the power of Flex development within reach of every professional application developer, while also offering value-added capabilities that scale to meet the needs of the most sophisticated enterprise projects. Flex Builder 2 will be sold for less than $1000 per developer and will include the ability to develop, compile, and deploy Flex applications that connect to XML and SOAP web services with no additional charges or server licensing required. Flex Enterprise Services 2 will be licensed on a per CPU, per project, and enterprise license basis to offer the development efficiency, performance, advanced integration capabilities, and testing support that advanced applications will require.”

Update: Mike Chambers has a round up of resources for Compiling ActionScript 3 and MXML from the command line.