Category Archives: Button

Creating toggle and emphasized Button controls in Flex

Pretty basic stuff, but if you’ve never used a toggle button in Flex or Flash, you may find this useful. The following example creates two Button controls. The first button sets the toggle property to true and determines whether the button is currently selected by watching the button’s selected property. The second button simply sets the emphasized property to true, which gives the button a nice visible border, making it stand out a little more than the other buttons. This is great for highlighting a default button in a form.

Full code after the jump.

Continue reading Creating toggle and emphasized Button controls in Flex

Disabling a Button control for a fixed number of seconds

I was installing a couple of Firefox plug-ins today and noticed the handy delay on a dialog window, which basically forces you to stare at the dialog for 2-3 seconds before you can press “OK”. Although it can be mildly annoying at times, I can see a lot of places where it would be nice to do that in a Flex application, even if it just helps to throttle user submissions (for example, a user couldn’t submit a feedback form for 3-5 seconds after the form was shown).

At any rate, I quickly threw this code together which creates a simple Flex Button control and disables it for 3 seconds. Naturally, I’m sure the code could be improved, or even possibly simplified if you didn’t want/need to update the button label with the counter, but hey…

Full code after the jump.

Continue reading Disabling a Button control for a fixed number of seconds

Setting a Flex Button control’s border color and theme color

The following example shows how you can change the Button control’s borderColor and themeColor properties to one of the special Flex “halo” colors (“haloBlue”, “haloGreen”, “haloOrange” or “haloSilver”). Note that you can also use any other named or hex color as well, such as “red” or 0xFF0000.

Full code after the jump.

Continue reading Setting a Flex Button control’s border color and theme color

Setting an icon in a Button control

There are two general methods for embedding an icon into a Button control. The first method involves creating a variable in the Flex application, and using the [Bindable] and [Embed] meta data. You specify the path to the icon in the source parameter of the Embed meta data and then to use the icon in a Button, you use data binding, which in this case would look like icon="{Icon}". The second method, embeds the icon inline in the Button tag itself, by using @Embed() and specifying the path to the image file as a parameter. See the full code after the jump.

Continue reading Setting an icon in a Button control