Home > Flash Builder > Tired of Typing? No More left=”0″ right=”0″ top=”0″ bottom=”0″

Tired of Typing? No More left=”0″ right=”0″ top=”0″ bottom=”0″

August 15th, 2011 Leave a comment Go to comments

I often find myself typing the same old snipped of MXML code over and over again.  Useful nevertheless, I’m getting tired it!  If you are like me, it’s time to automate this.  Fortunately  Flash Builder code templates feature is the perfect solution!  Jump after the break to see my new love in action.




This is how I created my new favorite template:

  1. Go to FlashBuilder -> Preferences -> Flash Builder -> Editors -> Code Templates -> MXML
  2. Click new template
  3. Type “left” for the name
  4. Select “MXML attributes” from the Context drop-down
  5. Fill in suitable description
  6. Paste the template body:
    left="${values}" right="${values}" top="${values}" bottom="${values}" ${cursor}
  7. Hit “Apply” and close the dialog


Now I’m ready to use it – I start typing “left” and hit the ^space to bring up the suggestions…


…then I select my template and Flash Builder inserts the body and places my cursor on the first field…


…I enter the value – in this case a single “0″ and Flash Builder fills in the values for all four attributes!


Finally, I press “tab” to get to the end of the code snippet and continue with the MXML.



PS : I looove code templates!  Almost as much as conditional breakpoints!!! ;-)


  1. Florian
    August 16th, 2011 at 01:58 | #1

    Thanks for the tip

    Can you explain what’s the difference between left=”0″ right=”0″ bottom=”0″ top=”0″ and width=”100%” height=”100%”?

  2. August 16th, 2011 at 09:31 | #2

    @florian They both equate to the same thing, although if you wanted a 5px gap on just the left or right it wouldn’t be possible using the width property. Likewise setting something to half the height of the parent would be difficult using top and button (especially if it can be resized).

    If you are using width 100% and height 100% then I would stick with that, but some developers tend to always use top/right/bottom/left because it makes it easier to change later :)

  3. Evtim
    August 16th, 2011 at 11:03 | #3

    One extra benefit to using left/right/top/bottom is that GraphicElements with stroke will be positioned on pixel boundaries. If using stroke with x/y then you’d need to offset by half of the stroke weight.

    For example using a Rect like the following

    <s:Rect width=”100%” height=”100%” />
    <s:SolidColorStroke color=”” … /> <!– defaults to 1 pixel stroke –>

    will place the stroke on half-pixel. Fortunately the player will then pixel-hint and nudge the horizontal/vertical lines and they will align with pixels so it will be unnoticeable. Unfortunately, if you’re using rounded corners, the curves won’t be pixel-hinted and the whole thing will look bad. The fix is to either use left/right/top/bottom or offset like this:

    <s:Rect width=”100%” height=”100%” x=”0.5″ y=”0.5″ />
    <s:SolidColorStroke color=”” … /> <!– defaults to 1 pixel stroke –>

    That’s the reason I always use left/right/top/bottom for all MXML graphic elements :)

  4. August 16th, 2011 at 18:22 | #4

    You can default to 0 as a value with the following:
    left=”${0}” right=”${0}” top=”${0}” bottom=”${0}”

    I named the shortcut tlbr because I use:
    top=”${0}” left=”${0}” bottom=”${0}” right=”${0)”

    it’s fast to type tlbr then ctrl-space

  5. November 21st, 2015 at 08:18 | #5

    Regarding the issue with:Could not create the view: Plug-in org.cfeclipse.cfml was uablne to load class org.cfeclipse.cfml.views.snips.SnipTreeView.Lee mentions that this is basically a tweaked version of CFEclipse’s SnipTreeView so the issue is not specifically with his panel not working, it’s actually an issue with SnipTreeView not working.I have/had SnipTreeView installed on a mac running 10.5 leopard and I also have it installed on my Macbook Pro which is running 10.6 Snow Leopard. I just formatted my iMac and put snow leopard on it and now SnipTreeView is giving me that error. All of my machines are running FB Beta 2. I think it’s weird that the install of flash builder i used on my laptop is the same as the install I used on this desktop, only a few weeks apart, so I feel like they should be identical.. and many people are reporting this issue several months back.Guess I have to keep googling. Seems like the messup is here:org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle org.cfeclipse.cfml (125).

  6. April 28th, 2016 at 18:20 | #6

    PC, yep my guess is Rudd will take some gardening leave until the election, and if rethe government is returned he’ll have a cabinet role at that point if he wants it.But whatever Julia does, she’d better check with Arbib and Shorten first.

  7. April 28th, 2016 at 18:25 | #7

    mindrider, for one thing they inherited the greeks and romans more directly, giving them a head start.But the evolution of the modern state took a long time, helped along by complexities absent in the Middle East. Chief among them a complexity of ideas and a growing belief in the right of the individual to shape his own destiny and national identity.These things are lacking badly in the Muslim world, where national identities are constructs that few take too seriously and the individual imperative is considered base not moral.

  8. July 14th, 2016 at 03:13 | #8

    I’ve not scrapbooked pictures of my dad because all my pics of him & my mom are so disorganized. I do have voice recordings of him telling stories and things about his life so when I do finally scrapbook pics of him I’ll need to figure out a creative way to get those recordings into my scrapbook.

  9. August 8th, 2016 at 07:22 | #9

    Thinking like that shows an expert’s touch

  10. October 7th, 2016 at 10:12 | #10

    For relaxing music, I would have to recommend some of Sarah McLachlan’s work. Her excellent voice really comes through in songs like “Angel” and “Full of Grace.”Amazon.com also gives you the option of listening to 30 seconds of music from any track of any CD they carry, which is a great way to find out the overall rythem of a song or group before you buy it.

  1. August 21st, 2011 at 21:03 | #1
  2. August 29th, 2011 at 10:02 | #2