Today one of my friends asked me if there is a way or any facility in Flex Builder to format a messy/unformatted code rather than doing it manually. There are no ways as such in the flex builder IDE which is based on Eclipse to provide indent to a particular block of code or to format a certain block of code. With the help of my colleague we found out that there is a plugin called Flex Formatter for Flex builder which will take care of the formatting of your code once you have made a messed up code in your application.
The Flex Formatter is an open source project which enables source code formatting of Adobe Flex code ie. MXML and AS 3.0 files inside FlexBuilder.
How to use it?
1. Download the project from http://sourceforge.net/projects/flexformatter/ which will have a WINRAR Zip Archive which is named as FlexPrettyPrintCommand_0.6.27.
2. Unzip this file and you will have three more WINRAR Archive file.
3. Copy the three zip files and goto the FlexBuilder folder in Windows where the Flex Builder files are installed.
4. Open the plugin folder and paste the three files there.
5. Close and restart your flex builder and now it is ready to use.
As soon as you restart the flex builder you will have 5 icons at the top in your toolbar as shown in screen below:
The Flex Formatter has the following features:
1. Format Flex Code (selected lines or documents).
2. Indent Flex Code (selected lines).
3. Re arrange AS code(whole file).
4. Generate AS Doc comments for files.
5. Generate AS Doc comment for current element.
I have tried the features with small blocks code and small AS files and it did work very well but I am still wondering how it will work with files which has more than thousand lines of code? Will the builder crash ?Need to check it out.Since writing a code which is messed up is not at all recommended when delivering an application, but developers who have to live with it have a simple solution using Flex Formatter. Plug it in your flex builder and see the difference for yourself 🙂