development


Hi! I haven’t posted anything in awhile because (besides my usual laziness) I’ve been travelling a lot lately, visiting customers as part of our user research for the next version of Flex and Flex Builder. We did a mix of watching people work and showing them some early feature concepts, and as always, both parts were very enlightening.

This post is about a simple but useful Flex component I wrote recently: the “self-labeling” text input field. Instead of labeling a text field the usual way, by putting a label to the left of the field, you can put the label inside the text input field itself (in a light gray color); when the user clicks in the field, the label automatically goes away. It’s a nice way to conserve real estate and make the UI less visually noisy. Here’s an example:

(The search box at the bottom is another little component that uses the self-labeling text input field. In this case, the borders of the actual field are hidden, so it blends into the surrounding container. I implemented it in AS for no particularly good reason—it could easily have been an MXML component with a tiny bit of script.)

You have to be a little careful when choosing to use this type of field, because the user can’t actually see the label when they’re typing in it, or when the field is already filled in. So it’s best used when:

  • the field’s meaning is obvious from context (e.g. the caption under a photo), or
  • there’s an icon associated with the field (as in the search box above), or
  • the form is very familiar, and the meaning of the fields is obvious even when they’re filled with actual content (as in the address example above; a username/password form would be another possible example).

Here’s the source code. Using the SelfLabelingTextInput is simple—it’s just like a TextInput with one extra parameter, label, that sets what the field should show when it’s empty.

Hope you find this useful!

[Update: Per Stacy Young's suggestion, I made it so the label also gets set as the tooltip for the field, so you can figure out what the field is even if it has content in it.]

Digg!digg this | del.icio.usdel.icio.us | 13 Comments

Brian Riggs of the Kiwi project has worked out a way to load graphical Flex skins at runtime. This could be useful if you want to create different themes for the same app without compiling them all in at once, or if you want to create an app like WinAmp that other people can skin without recompiling your source code.

Digg!digg this | del.icio.usdel.icio.us | 6 Comments

Jason Langdon took my reflection component and made a new version that adds blur, which actually makes it look a good deal more realistic (higher levels of blur make it look like it’s on a less polished “table”). Very cool.

Digg!digg this | del.icio.usdel.icio.us | 1 Comment

UPDATE 2/21/2008: See this post for the latest version of Reflector.as. I’ll reintegrate it into the source code linked to from this post eventually, but for now you’ll need to download the code from this post, then replace Reflector.as with the version from the newer post.

Okay, enough highfalutin’ chatter. This entry actually has (arguably) useful code in it.

The reflection effect is destined to become one of those gratuitous UI clichés, like brushed metal and gleaming highlights. But hey, the kids seem to like it, so I figured I’d try to make a similar component in Flex.

Before jumping into the explanation, here’s the demo:

You can drag the panel around to watch the reflection follow it, and play with the sliders to tweak the look of the reflection.

I’m not the first to attempt this: Trey Long created a reflection effect in an early beta of Flex 2 (the demo pointed to from that link no longer works with the shipping version of Flash Player 9). However, his version created static reflections—so, for example, you could see the reflection of a Button, but if you moused over or clicked on it, the reflection wouldn’t update to reflect (no pun intended) the visual changes to the Button.

I decided to make the reflection “live”—as you interact with the components being reflected, the reflection actually updates in (near) real-time. I also componentized the reflector itself, so you can just target it at a component and it automatically positions itself appropriately. I used code very similar to Trey’s reflection filter to render the reflection bitmap, though the way I actually draw it to the screen is a little different.

Read on for an explanation of the code: (more…)

Digg!digg this | del.icio.usdel.icio.us | 45 Comments

« Previous Page