Search

 

April 2009
S M T W T F S
« Mar   May »
 1234
567891011
12131415161718
19202122232425
2627282930  

Tags

Archives


« | Main | »

Flex Formatting, my new best friend!

By Rich Tretola | April 27, 2009
13,793 views

I recently stumbled across the Flex Formatting project for eclipse on SourceForge and it has made me so very happy! If you haven’t use this awesome plugin yet, you should as soon as possible. So, what does it do? Well, as the name suggests, it formats your ActionScript and MXML. Once you have this plugin installed, you have full control over how your code will be formatted. And now for the best part, you can simply set the formatted to automatically format your code when you save a file. So, there is no excuse for anyone to ever have ugly code again!

Here is what you should do as soon as possible.

Go to http://sourceforge.net/project/platformdownload.php?group_id=248408 and choose one of the installation options. I used the update site method as this is usually the easiest way to install any eclipse plugin.

Now, once you have the plugin installed, you can open up the preferences and tweak away, or just set to Adobe standards.

Here are some screen shots of settings:
ActionScript Settings:

MXML Settings:

Samples:
Here is a before:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
        [Bindable]
            private var hello:String = "Hello ";
            [Bindable]private var myName:String="Rich";
            private function init():void
            {
            //do something on creationComplete
}
        ]]>
    </mx:Script>
    <mx:Label horizontalCenter="0" verticalCenter="0" text="{hello} {myName}" fontSize="22" color="0xFFFF00" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
</mx:Application>

and after:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            [Bindable]
            private var hello:String = "Hello ";
            [Bindable]
            private var myName:String = "Rich";
           
            private function init():void {
                //do something on creationComplete
            }
        ]]>
    </mx:Script>
    <mx:Label horizontalCenter="0" verticalCenter="0" text="{hello} {myName}"
              fontSize="22" color="0xFFFF00" fontFamily="Arial"
              fontWeight="bold" fontStyle="italic" />
</mx:Application>

Topics: ActionScript 3, Adobe AIR, Announcements, Eclipse, Flex, Flex Builder | 11 Comments »

11 Responses to “Flex Formatting, my new best friend!”

  1. Andrew Westberg Says:
    April 27th, 2009 at 8:47 am

    I’ve used this plugin for about 4 months now. It’s not always perfect, but works great for what I need to do.

    Reply to this comment

  2. Tom Chiverton Says:
    April 27th, 2009 at 8:55 am

    However, beware of source control checkins that mix both code layout changes and code functionality changes – it may become hard to see what changed.

    Reply to this comment

    Carsten Schlipf Reply:

    Well, this is not limited to this plugin. It should be well known to every developer, that code changes and reformatings should not be done within one checkin.

    Reply to this comment

  3. Keith H Says:
    April 27th, 2009 at 12:08 pm

    I do ok keeping my scripts tidy, but sometimes my scripts turn into total spaghetti. I was in great need of this.
    Thanks for the link!.

    Reply to this comment

  4. Twitted by schmidt4brains Says:
    April 28th, 2009 at 8:48 am

    [...] This post was Twitted by schmidt4brains [...]

  5. New Eclipse Plugins for Flex Development | Davey's Flash Blog Says:
    April 28th, 2009 at 10:16 am

    [...] Rich Tretola blogged about a new Eclipse plugin for Flex code formatting (for Actionscript and MXML). This is great for those who want consistency in presenting their code.   [...]

  6. Twitted by flashtuts Says:
    April 30th, 2009 at 8:07 am

    [...] This post was Twitted by flashtuts – Real-url.org [...]

  7. Daniel Neri Says:
    May 1st, 2009 at 8:30 am

    Been waiting for something like this for a very long, long time.

    Thanks!

    Reply to this comment

  8. Robert Says:
    May 3rd, 2009 at 10:41 am

    Just super-duper!

    Reply to this comment

  9. Oscar Says:
    July 30th, 2009 at 4:26 am

    For the Eclipse-people who want to install this through URL instead of downloading the file, us this:
    http://flexformatter.googlecode.com/svn/trunk/FlexFormatter/FlexPrettyPrintCommandUpdateSite

    So you can automatically update when a new release is available.

    Reply to this comment

  10. Patrick Says:
    December 15th, 2010 at 7:46 am

    Does this plugin work with Flex Builder (not Eclipse)?

    Reply to this comment

Comments