Displaying the error indicator on a Spark FormItem container in Flex Hero

The following example shows how you can display the error indicator on a Spark FormItem container in Flex Hero by setting the errorString property or using the Flex validators.

The following example(s) require Flash Player 10 and the beta Adobe Flex Hero SDK. To download the Adobe Flash Builder 4 trial, see www.adobe.com/products/flex/. To download the latest nightly build of the Flex Hero SDK, see opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/ -->
<s:Application name="Spark_Form_Validator_test"
        <s:VerticalLayout horizontalAlign="center" verticalAlign="middle" />
            import mx.validators.Validator;
            protected function resetBtn_clickHandler(evt:MouseEvent):void {
                username.text = "";
                password1.text = "";
                password2.text = "";
                username.errorString = "";
                password1.errorString = "";
            protected function submitBtn_clickHandler(evt:MouseEvent):void {
        <fx:Array id="valArr">
            <mx:StringValidator source="{username}" property="text" required="true" minLength="4" />
            <mx:StringValidator source="{password1}" property="text" required="true" minLength="4" />
    <s:Form id="frm" defaultButton="{submitBtn}" backgroundColor="#EEEEEE">
        <s:FormHeading label="Spark Form Heading" backgroundColor="haloSilver" />
        <s:FormItem sequenceLabel="1." label="Username:">
                <s:Label text="user@domain.com" />
            <s:TextInput id="username" />
        <s:FormItem sequenceLabel="2." label="Password:">
                <s:Label text="weak" color="red" />
            <s:TextInput id="password1" displayAsPassword="true" />
        <s:FormItem sequenceLabel="3." label="Confirm password:">
                    <s:Label text="One" color="red" />
                    <s:Label text="Two" color="blue" />
            <s:TextInput id="password2" displayAsPassword="true" />
                <s:HorizontalLayout />
            <s:Button id="resetBtn" label="Reset" click="resetBtn_clickHandler(event);" />
            <s:Button id="submitBtn" label="Submit" click="submitBtn_clickHandler(event);" />

This entry is based on a beta version of the Flex Hero SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Hero SDK.