How to link SWC files to a TextMate Flex project
May 13th, 2009
I was recently asked how to compile using TextMate when you have precompiled SWC dependencies. This is a very common workflow but it’s unfortunately not as automatic as dropping them in your ’src’ directory. This is how to resolve the issue if you’re working with a folder structure built with TextMate’s Flex bundle (via File > New From Template > Flex > Project)
There’s a few ways to handle this. The quick way is to ensure that any SWC’s you use on any project are in your SDK’s frameworks/libs directory and that when mxmlc is run from the command line it runs from this SDK directory.
There’s two drawbacks to this method, however. One is that if you ever update your SDK you’ll have to migrate the SWC’s over manually (when it can often be unapparent which SWC’s are third-party and which are part of the SDK). You’d also need to have a redundant copy of SWC’s in each SDK you use (say you’re trying out both Flex 3 and Flex 4). Secondly, if you work with source control then there are code dependencies which reside outside the project folder, which is not ideal for anyone else that’s trying to collaborate with you, nor yourself if you’re trying to work on another machine. You could include your SDK in the source control, but this is not as compact a solution as sync’ing with the project folder itself.
So say we want to put all dependent SWC files in a ‘libs’ directory parallel our ’src’ directory, how do we do it?
To solve this, and potentially other future dilemmas, you really should familiarize yourself with the TextMate Bundle Editor (Bundles > Bundle Editor > Show Bundle Editor). Notice how there is no ‘Build’ option in the Flex bundle? This is because the Flex bundle also uses elements from the ActionScript 3 bundle. For example, if in the ActionScript 3 bundle you remove the keyboard shortcut for ‘Build’ and then change the ‘Build (mxmlc)’ keyboard shortcut to Cmd-B then you’ll remove a keystroke from your build process even in Flex projects. This is something I’ve personally done as I use mxmlc rather than the default Ant script to build. Remember to Bundles > Bundle Editor > Reload Bundles after making any changes.
But back to the issue at hand, open up Flex > Project > Project-config.xml. You’ll notice this is the schematic of a file which is created automatically when you create an Flex 3 project. Unfortunately, the Project-config.xml schematic in the Flex bundle lacks these two sample nodes that are in the ActionScript 3 bundle. These are:
<!-- Example library linkage -->
<!-- for swc's
<library-path append="true">
<path-element>../lib/bin/</path-element> </library-path> -->
<!-- for src
<source-path append="true">
<path-element>../lib/src/</path-element> </source-path>
-->
This file acts as a project-level override to the general configuration file found in the SDK directory. Close the bundle editor. You’ll want to add the following to your project’s configuration xml which lives in ’src’:
<library-path append="true">
<path-element>../libs/</path-element>
</library-path>
Now you can create a new directory named ‘libs’ parallel to ’src’ and drop into here all SWC files that your project depends on. Save the configuration file and you should be able to build. Now anyone with the Flex SDK will be able to save your project directory locally and jump right into compiling
You can also add any other project-specific compiler instructions in here. More information on your compiler switches options are here. For example, during a recent project I had a lot of unimportant warnings being fired with each compile so I was able to silence them with:
false
HTH.
Algorithmic crows (and the like)
September 10th, 2008
It’s a shame I’m only coming across this now, but better late than never. This recording, from FITC ‘08 Toronto, is a really inspiring take on how Robert Hodgin has used Processing to create some really amazing visual displays. He takes much of his inspirations from Perlin Noise, algorithmic repetition, and user-interactivity. If you’ve updated to the newest iTunes 8.0, you’ll see his work in the vastly improved visualizer.
EDIT: Unfortunately, it’s using an autoplaying video. For the sake of sanity, I’ve taken the embed out but you can click here to see it.
If you’re an OS X developer, chances are high that Eclipse really cramps your style. But don’t feel married to Flex Builder just because you want to export SWF files. My preferred IDE for the last year has been to use TextMate in combination with the Terminal for trace outputs. Long overdue, here’s my dangerously concise checklist of how to set this up for yourself:
- Download the debug version of the Flash Player (you should see ‘Debugger’ in the context menu of any SWF you right click upon if you have the debug player). Note as of this writing there is no publicly available Flash Player 10 debug player yet – you’ll need to stick with FP9 for now.
- Download and install TextMate.
- To setup command-line compiling, install the Flex SDK, or if you already have Flex Builder installed just set up your .bash_profile’s PATH to include ‘/Applications/Adobe\ Flex\ Builder\ 3/sdks/3.0.0/bin’. If all’s in order, you should get a positive response typing ‘mxmlc -help’ from the command line. If you’re not familiar with how to set up your .bash_profile, there’s plenty of sites with a little background on bash and how to do this.
- In order to trace debug and exceptions to your Terminal, you’ll need to grant access to the player. This process is obscure and esoteric, but do it once you’ll be set. If not already there, create a text file named ‘mm.cfg’ in /Library/Application Support/Macromedia/ and enter the following:
ErrorReportingEnable=1 TraceOutputFileEnable=1
Remember to quit all browsers and restart after making this change. - Now we’ll equip TextMate to be AS/MXML savvy. Leopard has Subversion pre-installed, which we’ll use to download the newest bundles from Macromates. Copy/paste the following into Terminal:
cd ~/Desktop svn co http://macromates.com/svn/Bundles/trunk/Review/Bundles/ActionScript%203.tmbundle/
After this has completed, you may as well do one more.
svn co http://macromates.com/svn/Bundles/trunk/Review/Bundles/Flex.tmbundle/
- One last Terminal line. This will convert your Terminal into a trace output window for testing SWF files. You’ll need to do this every time you start Terminal up.
tail -f ~/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt
- OK. Go to your Desktop and double click the bundle files that have just been created.
- Now from within TextMate, go to File / New From Template / ActionScript 3 / Project. (Fn-Cmd-F2 gives you keyboard access to the menu bar, if you fancy)
- Specify a location for your new SWF project folder, and fill out the main class namespace (defaults to org.domain.AS3Project)
- Cmd-Shift-B to initiate a build, hit ‘5′ to select MXMLC. You’ll see the build’s success or failure in the subsequent pop-up.
- Cmd-W to close the pop-up. Cmd-R to open the SWF in its HTML container in your default browser. Note that the default project structure doesn’t do anything visually, but it does include a trace. So something along the lines of ‘AS3ProjectTest::initialize()’ should be output to your Terminal at this point.
And you’re good to go! You’ll notice right away that TextMate is a very bare-bones editor. But its simplicity obscures its complexity. Snippets and completion are two of its many benefits. You can familiarize yourself at the online manual.
As an added bonus, check out the free utility Visor (from the creator of Quicksilver). It’s a little odd to set up, but once it’s there, while focused on any other application you can press any specified keyboard shortcut to slide out a terminal window from the top of the screen, giving you an easy glance at what your SWF may be tracing.
Enjoy! Feel free to add your own tips below.
A gathering of commentary on Flash Player support of AAC/h.264
September 9th, 2007
Given the tumult of the change in my day job, it’s been difficult for me to keep up with the fallout of Adobe’s announcement of rudimentary support of AAC and h.264 codecs in a beta release of Flash Player 9. (For a start, you can read the formal announcement and/or the more technical explanation of the limitations from Tinic Uro, an engineer on the Player team.)
In the two weeks hence, there’s been a lot of talk about the implications. As far as I can gather, no major player in web video has made the beta player a requirement to any public-facing player, but it wouldn’t surprise me if we see this soon – YouTube may have name recognition, but undoubtedly the video-on-the-web market is a cutthroat arena with many competitors. Of course, offering h.264 support means a potential migration from the current status quo – that of On2’s VP6 codec, supported in Flash Player since version 8. On2 of course isn’t taking all of this lying down. They’ve released an FAQ that highlights how sticking with their codec is still advantageous in specific scenarios. There’s even a community that prefers to sidestep the Flash Player entirely in favor of streaming DivX. Some even see Microsoft’s impact on the decision. But all said, there’s little question where the momentum lies given the rabid response to h.264’s inclusion into the Player.
I’m excited to see where this goes. There’s already some interesting demos, write-ups and commentary on the subject and there’s certainly a lot of dust yet to settle, especially given Adobe’s related announcement of Flash Media Server 3.
For those interested in exploring the new technology, understand that there are some important limitations to the beta release. Most noticeable is that only a subset of h.264 movies are currently playable. A significant number of encoding tools place the index information of an h.264 .mov file at the end of the file – this needs to be moved to the front in order for the file to be playable in a SWF. Renaun Erickson has created an AIR application which attempts to do this for you.
For more information, begin with Tinic’s article, as well as an optimization note from Adobe.
Also a note on metadata support.