03
Mar
08

Setting a custom required indicator skin on a FormItem container in Flex

The following example shows how you can set a custom indicator skin on a Flex FormItem container by setting the indicatorSkin style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/03/setting-a-custom-required-indicator-skin-on-a-formitem-container-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        FormItem {
            indicatorGap: 24;
        }
    </mx:Style>

    <mx:Form>
        <mx:FormHeading label="Controls" />
        <mx:FormItem label="Button:"
                required="true"
                indicatorSkin="@Embed('assets/Button.png')">
            <mx:Label text="Lorem ipsum..." />
        </mx:FormItem>
        <mx:FormItem label="ButtonBar:"
                required="true"
                indicatorSkin="@Embed('assets/ButtonBar.png')">
            <mx:Label text="Lorem ipsum..." />
        </mx:FormItem>
        <mx:FormItem label="CheckBox:"
                required="true"
                indicatorSkin="@Embed('assets/CheckBox.png')">
            <mx:Label text="Lorem ipsum..." />
        </mx:FormItem>
        <mx:FormItem label="ColorPicker:"
                required="true"
                indicatorSkin="@Embed('assets/ColorPicker.png')">
            <mx:Label text="Lorem ipsum..." />
        </mx:FormItem>
    </mx:Form>

</mx:Application>

View source is enabled in the following example.


3 Responses to “Setting a custom required indicator skin on a FormItem container in Flex”


  1. 1 John McPeek Mar 7th, 2008 at 10:59 am

    Can you put the indicator on the left side of the label like ‘*blah’?

  2. 2 René Mar 11th, 2008 at 1:08 am

    Can you change the indicator skin at runtime as well ?
    Or put more practically: How can I make the FormItem display different icons depending on the content of associated Text-Fields ? For instance to show the default red one when the field is empty but switch to green when filled ?

  3. 3 peterd Mar 11th, 2008 at 2:00 pm

    René,

    I tried a quick test but wasn’t able to get the indicator skin to change at runtime.
    I’ve filed a bug at http://bugs.adobe.com/jira/browse/SDK-14925. Feel free to sign up for the bug base if you haven’t already and subscribe to the bug.

    Thanks,
    Peter

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".




Badge Farm

  • Firefox 2
  • Powered by Redoable 1.2
  • Feeds burnt by Feedburner
  • Feed