Recently I’ve been introduced to a code formatter for Flex Builder 3 and thought it was worth sharing. The plug-in formats, indents and rearranges both MXML and ActionScript code.
Downloading the plug-in
There is a version of the plug-in available here, but I haven’t installed it from there. Below I’ve included instructions on how to install the plug-in using the software updates feature in Flex Builder.
Installing the plug-in via Software Updates
- Launch Flex Builder 3 and go to Help>Software Updates>Find and install…
- Check the Search for new features to install option and click Next
- Now create a New Remote Site…
- Enter the following URL for the remote site and give it a name, such as Flex Code Formatter and click Finish:
- Browse the tree to find the code formatter plugin ( FlexPrettyPrintCommandFeature Feature 0.6.27 ) and click Next.
- Accept the license agreement and click Next then Finish.
- Click Install All and restart Flex Builder 3. The plug-in is now installed and ready to use.
Using the plug-in
Once Flex Builder has restarted you should notice a new toolbar with some black and white icons. This toolbar gives you access to the following features:
- Generating ASDoc comments for the file
- Generating ASDoc comment for the current element
- Format code
- Indent code
- Rearrage the code of the file
There will also be a shortcut key set up for formatting code; the default is CTRL+SHIFT+F.
Editing the Preferences
To edit the preferences of the plugin go to Window>Preferences. Then browse to Flex Formatting using the tree navigation on the left. There are a vast array of formatting and restructuring options available, so you should be able to find something to suit the way you code. It is also worth browsing the navigation tree to show the options for Auto Format; this will give you the option to format or indent code when you save.