My Conversion to Flex, and How to Use Xcode with Flex 2
by Josh on Feb.06, 2006, under Flex, Mac
Update: I have updated these instructions to work with the final release of the Flex SDK. The new location is:
I’m going to be honest. Until recently, I just couldn’t see what all the big fuss over Flex was. Sure, it seemed neat, but I just couldn’t see the point in using it when a lot of the stuff it offered I figured I could just build myself. The price tag was also a big turnoff.
However, with the news that the Flex SDK will be available free of charge, that was a good push in the Flex direction for me. The other thing that’s changed my mind on Flex is having actually used it.
While at MAX, I attended one of the “Hands-On” sessions where we built a simple Flex application, that took around 20 minutes of actual development time. That same app would’ve taken about two hours for me to do from scratch in Flash. Also, over this last weekend, I spent some quality time with the Flex Builder Beta on my Windows machine. (My Mac was busy rendering some videos for something.)
I started building the interface for a project I’ve been working on for a while, and in about an hour’s time, I had the login, password recovery, “My Account”, and Dashboard areas completed. Again, something that would’ve taken much longer in Flash.
I’m sold.
However, as people know, I’m a Mac guy at heart, and as nice as Flex Builder is, I still really like using my Mac. Once it’s available for the Mac, most likely I’ll be using it. However, until then, I’d still like to work on my Mac. I’ve set up an Xcode project template that can be used to build a Flex application, using the latest mxmlc compiler from the Flex 2 beta.
Building Flex 2 Apps in Xcode
To use Xcode, you’ll first need to do some setup:
- Download and install at least the Flex Frameworks from labs.macromedia.com. You’ll need to do this on a Windows machine. Once it’s done installing, from the install directory, copy the “lib” and “frameworks” directories to your Mac.
- Copy these files to “/Developer/SDKs/Flex”. You may need to create this folder.
- Download this project template, and copy it to “/Library/Application Support/Apple/Developer Tools/Project Templates/Flash”. You may also need to create this folder yourself.
- If Xcode is open, restart it, and create a new project. You should now have a “Flash” heading in the project type list, with “FlexApplication” under it. This should create a new Flex project, with a bare-bones MXML file. If you click the build button, Xcode will start up mxmlc to compile the included MXML file. Just remember to base your application off of this file for the compiling to work.
However, if you’d still like to just use the command-line to run the compiler, you can still do so, however, it appears that some of the syntax has changed. You now need to specify the config file to use, so the command to compile would now be like so:
java -jar "/Developer/SDKs/Flex/lib/mxmlc.jar" -load-config "/Developer/SDKs/Flex/frameworks/flex-config.xml" -file-specs myFileName.mxml
Of course, you’ll need to make sure that the paths to the config file and mxmlc.jar match your system. (Thanks Jules)
Hopefully we Mac users will get some Flex/AS 3.0 lovin’ from the Adobe Labs soon, (Lightroom is nice, but Flash/Flex would be nicer,) but until then, I guess we’ll just have to make do with these methods. Have fun!
February 6th, 2006 on 8:16 AM
[...] http://www.joshbuhler.com/2006/02/06/my-conversion-to-flex-and-how-to-use-xcode-with-flex-2/ [...]
February 6th, 2006 on 3:47 PM
Thank you so much Josh. I’ve been impressed with Flex from the beginning, but over the years I’ve developed my own guideline that goes something like, “if they don’t make it for Mac, it’s not worth it.” The reason I use a Mac for being a designer and a developer is the same reason I’d be using a Lexus or BMW if I was a traveling salesman of any sort. If I’m going to spend so much time behind the wheel, I’m certainly going to opt for the best experience available to make life more enjoyable. Refusing to use Flex for this reason says a lot because as enticing as it truly is, I’m not going to start clunking around the digital universe in a Ford Tempo-esque jallopy just to gain access to it. Sincere thanks to you for sharing this great information, I’m looking forward to getting started with it asap, until Adobe eventually figures it out. As Mac users know, a tough part of being a Mac user is the fact that we get used to being anywhere from one to five years ahead of many of the features Windows users lack, while at the same time, the “herd” adds up to more money, which can often mean Windows sees certain packages first. (and no offense to those who have enjoyed driving to work in their old reliable Ford Tempo over the past 20 years, if it works for you, great!) Thanks again!
February 16th, 2006 on 4:48 PM
Make sure that you put the template in “Project Templates”. I put it in “Target Templates” and it took me a few minutes to figure out why I wasn’t seeing the new project in XCode.
Other people are using Eclipse succsfully.
http://www.google.ca/search?hl=en&q=flex+eclipse+mac&btnG=Google+Search&meta=
March 18th, 2006 on 5:36 PM
Come on Adobe/Macromedia, when are you going to get your head in the game? How amusing that a product so geared at providing the rich user experience, won’t offer the Flex 2 running-headstart to users prefering the definitive rich user experience (OS X). If Adobe/Macromedia wants to harness the cunning of the savvy designers and developers, they had better start to realize that those who appreciate top-tier design and development, are also found amongst great design and development. Simple FYI Adobe, there’s a lot of us over here with OS X ready and willing once you get it together. Until then, god speed to the generous genius of people like Buhler, the genuine article.
March 20th, 2006 on 10:40 AM
I made the install successfully but I am unable to compile. I get the following message (It seems to be looking for a defaults.css any ideas?):
/usr/bin/java -jar /Developer/SDKs/Flex/lib/mxmlc.jar -compiler.include-libraries /Developer/SDKs/Flex/frameworks/ -load-config /Developer/SDKs/Flex/frameworks/flex-config.xml -file-specs flexTest.mxml
Loading configuration file /Developer/SDKs/Flex/frameworks/flex-config.xml, root element flex-config
Initial setup: 520ms
Loaded 6 SWCs: 1351ms
License Service: Unable to open license file.
License Service: Flex 2.0 Developer Edition enabled (beta period ends May 1, 2006)
Compiling…
defaults.css(-1): Error: macromedia.css.LocatorParser
Total time: 6176ms
March 23rd, 2006 on 3:53 PM
[...] It’s still no FlexBuilder, which hopefully isn’t too far off, but it’s still a lot better than nothing. It’ll at least save you the work of having to download the Windows files and strip out the stuff you need to compile on your Mac. [...]
March 30th, 2006 on 3:24 PM
Ok for some reason Flex beta 2 is not working for Xcode. I read the release notes for beta 2, but I can’t get a simple hello world message. I downloaded the Flex beta 2 SDK and I think its the compiler. Another hault on Flex application development on Xcode. So I bite some of those words I posted on march 17th. LOL I update flash player 8.5 and its not displaying the text. Also is there a sytax change in mxml in beta 2?
April 8th, 2006 on 3:33 PM
My last comment is missing some info. I’ll try again…
I tried the test and the first thing that fails is the namepsace which should be:
mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
I tried the hello world example from labs:
?xml version=”1.0″ encoding=”utf-8″?
mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
xmlns=”*” layout=”absolute”
mx:Label text=”Hello World”/
/mx:Application
The project then appears to build succcessfully but nothing appears in the swf. On decompiling it I find empty movieclip code:
movieClip 3 {
}
I suppose this is what you mean when you say it doesn’t work 100%
April 17th, 2006 on 5:39 AM
Hi, just want to correct the url in the previous post: you can get the as3 code completion at http://opencode.forabettertoday.org
have fun
kp