skip navigation links

The Internet's only wheelchair-accessible website.

blog

software/ui/flex

Setting background image position for a HBox / VBox in Flex

(April 24th, 2009 - 1:21AM)

If you're reading this, you're probably looking for a way to position a background image on your Flex VBox or HBox. So was I. I find it amazing that Flex doesn't support this out of the box.

There were a lot of solutions online, such as a very clever one that involves overriding createChildren (you can see it here). However, this is an awfully heavy (and potentially risky) solution for what should be a very simple problem.

I came up with a way of positioning my background images. It's not perfect, and it won't work in all situations, but it's relatively simple and will hopefully do the job until Adobe officially supports it.

Here's what I did. The example below adds a right-aligned background image (imgBadge) to the vbxDisplaying VBox.

<mx:VBox
    id="vbxDisplaying"
    width="100%"
>
    <mx:HBox
        id="hbxBadge"
        width="{this.width-imgBadge.width}"
        horizontalAlign="right"
        verticalAlign="bottom"
        includeInLayout="false"
    >
        <mx:Image
            id="imgBadge"
            source="@Embed('/images/rock_badge.png')"
        />
    </mx:HBox>
    <!-- some other elements here... -->
</mx:VBox>

Here's the end result. The rounded box is vbxDisplaying, and the Web 2.0 badge is imgBadge.

A screenshot of the above code sample.  Shows a badge being right-positioned in a VBox.

Basically, I'm using the includeInLayout property of the HBox/VBox to pull my image out of the flow of elements. I'm not using the backgroundImage property at all. For those who haven't used it before, includeInLayout allows you to create a visual element that doesn't push elements aside to make space; it can have an effect similar to absolute positioning in HTML.

By doing this, I'm spoofing a background image that's aligned to the right.

I know this isn't a perfectly elegant solution - it would be a lot nicer if this could be done through CSS - but it's a really easy fix and will hopefully be good enough for now.

permanent link - digg this post - 1 comment
work/contracting

5 reasons to avoid microbusinesses

(April 12th, 2009 - 9:43AM)

There's nothing wrong with small businesses. My best clients are small businesses. But be very careful when planning to do work for microbusinesses.

A microbusiness is defined as a business with 5 or fewer employees. There's nothing necessarily bad about being so small - heck, my own company is a microbusiness - but from my experience, microbusinesses often share the following characteristics:

  • They're excessively cheap.

    Frugality can be a virtue, particularly in our current recession. But microbusinesses tend to be excessively frugal. When microbusinesses make purchasing decisions, the sole factor they often consider is price. Not quality, not ROI, but price.

    So when you bid on a project for a microbusiness, you'll find they don't care about your qualifications or expertise; they just want to know if you're willing to work for $10/hr. Not only is this a bad trend for your career, but it cheapens our discipline as a whole when people are willing to work at subsistence wages.

  • They're unprofessional.

    Most of the time, microbusinesses are small because they have no desire to grow. This is fine. However, some microbusinesses remain small because they lack the business skills to expand. These are the ones you have to look out for.

    I once worked with a microbusiness software house that had remained tiny for over 30 years - an eternity in the software world. And it was not their intention to remain this small - they simply didn't have the talent on staff to grow. There are reasons why companies like this are unable to grow past the micro stage, and I highly recommend avoiding them unless you want to experience their deficiencies first-hand.

  • Their referrals aren't very good.

    Birds of a feather flock together. If you have a cheap, difficult microbusiness as a client, the best referrals you'll get are to other cheap, difficult microbusinesses. Break the cycle and look for better clients, rather than relying on lousy referrals.

  • They demand more than they've paid for.

    A lot of microbusinesses will try to suck you in for unpaid work. This is unfortunate, because it prevents you from taking on other lucrative contracts.

  • The likelihood of project failure is high.

    For the reasons listed above, it's extremely likely that projects done for microbusinesses will fail. And even if you do succeed in completing these projects, it will often be done so at a quality level that you find unacceptable. Unfortunately, this doesn't bode well for your portfolio and career development.

For these reasons, you should be very careful when engaging with microbusinesses. That being said, not all microbusinesses are bad - in fact, I've worked with a lot of microbusinesses that have been an absolute joy. However, microbusinesses are, on average, more difficult clients than small businesses, so be very careful when taking on a client in this situation.

permanent link - digg this post - 1 comment
  older entries
mail@stevekwan.com