ComboBox.prompt

This is one of those little things that you come across from time to time and think to yourself, “man, how did I not come across this before?”.
There has been so many times where I have added an item to a collection in order to display a message to the user. For instance, say you have a ComboBox that displays a list of employees and you want to add a message as the first item, specifying something to the extent of “Select an employee”. Typically, an item would need to be added to the dataProvider of the ComboBox at index 0. Then the issue arises where you will then need to take this item into account when it is selected so that it will be ignored.

Well, like most things in Flex there is an out of the box solution!

The solution is the prompt property which can be utilized to facilitate exactly this sort of thing. I stumbled across this property accidentally while extending ComboBox and viewing the source code. The prompt property simple adds an item to it’s data provider at -1. Since Array indexing begins at zero, this item is ignored and you do not have to take it into account when working with the data provider.

  1. <mx:ComboBox prompt=“Select an employee” />

Hope this helps someone down the road.

Introducing Cairngorm Creator

Cairngorm Logo

After discovering all the benefits the Cairngorm micro architecture, I quickly found that creating all the classes and mxml files was quite tedious. Thus Cairngorm Creator was born. Cairngorm Creator is a Flex code generation application that enables developers to quickly define and create a Flex application skeleton based on the Cairngorm micro architecture.

    Current Features

  • User-defineable package name
  • User-defineable folder names
  • Custom build file
  • Save and Load structure definitions (XML)
  • Editable source XML
  • Preview Files
  • Downloadable Zip File

Cairngorm Screen
Cairngorm Screen 2