Being a Ruby lover I’ve always intended on using Sprouts for project management. But when I was last looking for a solution you couldn’t easily specify which revision of a Flex SDK a project should be built with. This was something we needed to do. Access to the continuos integration box was limited which also caused problems, so we went with ant. I’ve been rolling out the same ant scripts and associated libraries into projects ever since. Code should be DRY, so why not your projects?

Minimalism in action

Maven has always been on the radar, but Flexmojos has made it all the more attractive to flash developers so there’s been more and more chatter about it recently. At work it’s been talked about for while, and after a sales pitch from Mischa, I’ve finally started to put it into action. So far it’s really cool, simple, clean, and consistent. The projects I’ve converted just end up with test and src directories. A lot of junk is gone, reduced to a few lines in a pom.xml file. They’re smaller and easier to understand. Just the kind of minimalism I like.

Getting an overview

Starting by understanding how Maven works is a sensible idea, for this try Maven:The Complete Reference. Then, for flex related tasks the Flexmojos site is a good source of information. Keeping an eye on the Flexmojos mailing list also helps.

Installing maven 2 + 3

Maven comes preinstalled on OS X so type mvn --version into the Terminal and you’re likely to see this:

Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100)
Java version: 1.6.0_20
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: en_GB, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac" 

This means you’re good to go with all versions of Flexmojos prior to 4.x but you’ll need to install Maven 3 if you need to use any of the features in 4, as I’m after AIR compilation, and ASDOC builds against Flex SDK 4 I needed to install the Maven 3 beta.

To start with download it, then unzip to /usr/local/apache-maven/apache-maven-3.0-beta-1. You’ll then need to edit your ~/.profile to include the following:

export M2_HOME=/usr/local/apache-maven/apache-maven-3.0-beta-1
M2="$M2_HOME/bin"
PATH="$M2:$PATH"
MAVEN_OPTS=-Xmx1024m

The last line isn’t necessary, but I added it to give Maven a little more memory to work with. The install notes also say you need to set JAVA_HOME. I didn’t find it necessary, but if you want to then finding out where JAVA_HOME is on a mac means running /usr/libexec/java_home (should be the same as what Maven’s just told you above) and adding the results to your ~/.profile. For me this was:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

Running tests also meant doing a little bit of work. If they don’t work for you then you may need to tell Flexmojos where to find your install of the standalone flash player. So going back to your ~/.profile you will need add the following:

PATH="$PATH:/Applications/Flash Player Debugger.app/Contents/MacOS/"

Then your pom file needs the following added to the flexmojos-maven-plugin configuration node.

<flashPlayerCommand>Flash Player Debugger</flashPlayerCommand>

There’s a full example of this here

Concluding with poms

Once installed maven is designed to automatically fetch all the resources it needs. This is done via configuring your pom files to reference the right artifacts so that maven can retrieve them. Where a dependency can’t be found online you have the opportunity to install it locally. So far I’ve used the documentation and found example files and have been reasonably productive. This example pom tests, compiles, validates and generates asdocs for a swc library I’m experimenting with. I’m looking to expand this to include swf + air compilation, and test coverage reports.

As Flexmojos 4.x is still under active development it can be tricky to get something to work as expected, you do need a little patience. But that is to be expected with alpha software. Version 3 doesn’t offer the full feature set I’d like so at the moment maven doesn’t feel like the complete solution. But as the source is now on github so maybe I can find some time to help out. Overall I’m totally sold on the concept and am looking forward to 4.x moving into stability.

Going Git

February 24th, 2009

Git is one of the tools I’ve been meaning to try for a while now. It’s a version control systems that offers a distributed model, is fast, light and perfect for branching and merging.

I was pretty confident I’d be up and running quickly with git as I’m used to subversion. But given the past few days experience I wouldn’t say it’s been easy. It may have been, but I decided my way in would be to mirror both the Flex and ActionScript 3 TextMate Bundles over on github – which meant using git svn. In principle it looked straightforward, but after a few clumsy maneuvers I was quickly disorientated (mainly because git svn dcommit happens to rebase on the quiet). I don’t think I’m out of the woods yet but am really beginning to see what all the noise over git is about. It’s well worth the initial steep learning curve.

What I’m hoping to see are forks of the bundles, new features, feedback, and maybe one or two bug fixes ;) There are some branches to try as well. One or two build solutions have been cooked up but not quite finished. Alongside a basic attempt to integrate fdb, but it still needs a UI bolting on the front to offer true integration.

Oh, and for those of you who’ve been waiting for the auto-completion alpha then that’s in the main bundle now. Take a look at the ‘Auto Complete’ command – I’ll post a little more about it soon.

The ActionScript 3 bundles had the ability to auto import a class for a long time, but the functionality has been limited to the area of the document between the package and class declarations. There have been some interesting solutions to improve this workflow, but ultimately it needed a more elegant solution.

If you grab the most recent version of the bundle you’ll now find that ⇧⌘I can be invoked from a wider scope and will present you with a list of possible classes to import based on the current word. Select one and an import statement for the class will be generated and injected into the document (or a tooltip saying the class is already imported).

I ought to stress that the importing is improved, but needs more work. The command is scoped to work within a public class, so any private classes hiding beneath your package block won’t benefit. You’re also likely, if you’re tidy, to want to organise the imports statements later on. But what is great about this is it let’s you skip a repetitive task and focus on higher level logic.

AS3 Autocompletion in TextMate

September 26th, 2008

Here’s a little teaser showing autocompletion for ActionScript 3 in action using TextMate.

It’s work in progress and I’m planning on releasing it for testing once Dialog 2 moves out of review. I also need to add the functionality to search multiple ancestors in interfaces to resolve the type of an item.

I’ve quickly put together a bundle for working with JSFL, or the Flash JavaScript API. If you’re not familiar with JSFL it is used to automate and extend the Flash IDE. The bundles language grammar relies on the JavaScript bundle being installed (which is one of TextMates default bundles) as it extends it and adds all of the JSFL objects, methods and properties. You also get:

Run (⌘R)

Runs the current document in Flash.

Documentation (⌃H)

Searches the documentation and presents a list of matches. As I only have access to machines with Flash CS3 installed I don’t know the alternative paths to the documentation previous (and later) versions of Flash use so please drop me a line and I’ll include them.

Auto Complete Method / Property (⌥⎋)

Provides a pop-up list of the available method and property completions based on the current word.

I’d recommend checking out the bundle from here for the most up to date version, otherwise you can download it as a zip here.

JSFL Bundle

HelvectorLight Theme

December 23rd, 2007

I’ve just updated the ActionScript 3 Bundle to include an ASDoc language definition. This is essentially a scope change of Luke Daley’s JavaDoc language definition. The result is that the following scopes within the documentation blocks are brought under new colour jurisdictions.

keyword.other entity.name.tag punctuation.definition.tag

For me, using my favourite theme – Twilight – the extra colour where I was so used to seeing grey wasn’t working. To combat it, and get things greyscale again, I added 3 new theme elements and applied them to the following scopes:

comment.block.documentation keyword.other comment.block.documentation entity.name.tag comment.block.documentation punctuation.definition.tag

The results are the HelvectorLight.tmTheme which calms things down again.

Download

I share one of my development machines with another flash developer and have run into a problem whereby the debug flash player was only available to the user who installed it. Trying to set more generous permissions on the plug-in didn’t work. So I simply changed the name of the plug-in by prefixing it with the installing users name then reinstalled it as second user. This leaves you with multiple instances of the flash player in Library/Internet Plug-Ins but as each user only has permission to use the player they installed no confusion arises.

The most recent debug player can be found here. An archive of debug players can be found here.

As a Flash developer who’s been working with Flex and ActionScript 3 since late last year I found I couldn’t settle down and use the Flex Builder Eclipse plug-in. Previously I had acquired the habit of editing ActionScript using TextMate and compiled using the lightning fast MTASC, and although there were alternatives (FDT, Sepy), I’ve always preferred the lightweight flexibility and crisp feel that TextMate has. As a result I’m responsible for TextMate’s ActionScript 3 and Flex bundles.

At the moment the bundles are in the review section of the TextMate Repository. Once installed the bundle help covers how to set up (primarily to download the flex sdk) and outlines the non-obvious commands.

The main highlights of the bundles are:

  • MXMLC and FCSH Build Commands.
  • Function, Tag, Import Auto Completion.
  • ActionScript 3 and Flex documentation search.
  • Drag and Drop of imports, includes, embed assets, css, xml.
  • ASDoc Support.
  • MXML Validation.
  • Manifest Generation.
  • Class and Component Templates.
  • Flex Builder compatible project creation.
  • Unused Import statement removal.
  • Shortcut Key Super Class, Code Behind and Import file opening.

Thanks to the following people who have all had a hand, although they may not know it, in the creation of the bundles:

For those of you who don’t use subversion the following zip’s can be downloaded, but they won’t necessarily be the latest version :

ActionScript 3 Bundle Flex Bundle

I wrote the following shell script a while back for use with TextMate as part of my build process. TextMate’s great as it easily allows you to bind scripts to custom commands (and key combinations). However you’d easily be able to adapt it to your set up. It will allow you to cleanly change all the flash players available for OS X, as well as being able to Uninstall the player, and optionally restart open browsers (FireFox and Safari) afterwards.

You’ll need to download the players, install and move the files into archived folders the contents of which the script will copy to the default internet plug-ins folder. It shouldn’t be too difficult to work out how this happens and alter the script for your needs.

Download the script here

To install the FP 7.0.14 without restarting any open broswers:

changePlayer.sh 7.0.14 false

To uninstall the flash player:

changePlayer.sh uninstallflashplayer

To install FP 6.0.49, restarting open browsers:

changePlayer.sh 6.0.49

If there’s anyone out there using TextMate and would like a the above wrapped up in a bundle then please email me and I’ll send a copy over.

Fork me on GitHub