Skip to content
July 5, 2009 / edeustace

Organizing imports and namespaces in Adobe Flex mxml files

Adobe Flex Builder has a lovely feature in the editor to allow you to organise your imports in your .as files. Ctrl+Shift+O (the letter), will sort your imports and remove any unused imports. However this isn’t enabled for .mxml files. I’ve just been playing with the new Flash Builder and its still not there.

On top of that, even if they ever to add the mxml sorting feature, they’ll probably keep it to one file at a time.. as  it is for actionscript.

Due to this, I wrote a ruby script that performs this job. I have open sourced it, its available at http://code.google.com/p/mxmlcleaner/.

What is there is the original ruby script, plus an expirmental Ant Task, that wraps the ruby and runs it with JRuby. This is working, but requires that you put JRuby into your ant home /lib folder.

When I get time, I’ll port the script to run natively on the JVM.

Also, the organiser for the mxml root node’s attributes are governed by an external rules file. I need to do a bit of refactoring so that the user can specify their own rules.

I hope it saves you some time in tidying up your mxml.

Finally the google code project has the link to the feature request in bugs.adobe.com, be sure to vote.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: