Code Formatting for Flex Builder 3

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.

Code Formatting for Flex Builder 3

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

  1. Launch Flex Builder 3 and go to Help>Software Updates>Find and install…
  2. Check the Search for new features to install option and click Next
  3. Now create a New Remote Site…
  4. Enter the following URL for the remote site and give it a name, such as Flex Code Formatter and click Finish:
    http://flexformatter.googlecode.com/svn/trunk/FlexFormatter/FlexPrettyPrintCommandUpdateSite
  5. Browse the tree to find the code formatter plugin ( FlexPrettyPrintCommandFeature Feature 0.6.27 ) and click Next.
  6. Accept the license agreement and click Next then Finish.
  7. 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.

Posted by Mark on September 10th, 2009
 

13 Responses to “Code Formatting for Flex Builder 3”

  • Adam Says:

    Thanks! This is just what I was looking for.

  • mark Says:

    I love you! I found it so stupid that adobe took eclipse (which HAS code auto formatting) and somehow didn’t tweak it for actionscript code (whose syntax is very similar to java!)

    Looking at messy code is very very annoying, and I am visibly estatic that I finally found a way to auto format actionscript code! kudos =)

  • Mark Says:

    @mark I’m glad you found it useful! I hate looking at messy code too, it was horrible picking up someone else’s work until I started using this! Thanks for the comment Mark.

    Mark ( @mark_star )

  • Valdemar Says:

    Thank you. It is very helpful.

  • Jean Kiepura Says:

    Google is my friend and helped me find this link to Flex’ most notable Missing Feature! Thanks for the tip

  • Rahul Gajre Says:

    Ausome buddy! Thanks a lot! I will be gr8ful if u find the same plug in for flashDevlop software.

  • Arup Bhattacharya Says:

    Thank you very much. This is an awesome feature and extremely helpful. The plug in has further editable parameters to suit ones need. Thanks a lot.

  • Marc Benson Says:

    This has made my life so much easier!!! Thanks

  • Varun Soni Says:

    This is really cool. I am from Flash background and was looking for this type of time saving thing. Thanks.

  • suchmaschinen anmelden Says:

    Nice Post..!

  • KM Says:

    Great post.

    Incidentally, Flex 4 (Flash Buider 4) now HAS formatting and indenting as standard

  • Mark Says:

    You’re right KM. It does, however it doesn’t have the plethora of formatting options that come with the code formatter. I’d strongly recommend using the code formatter still, especially if you’re working in a team.

    Mark

  • AutoFormat AS3 in Eclipse | Flex Says:

    [...] ?????: http://markstar.co.uk/blog/2009/flashplatform/flex/code-formatting-for-flex-builder-3/ ?????????? ? ???. ????? ? ??? [...]

Leave a Reply