<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; Validator</title>
	<atom:link href="http://blog.flexexamples.com/category/validator/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Displaying the error indicator on a Spark FormItem container in Flex Hero</title>
		<link>http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/</link>
		<comments>http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 06:42:54 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Form (Spark)]]></category>
		<category><![CDATA[FormItem (Spark)]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[Validators]]></category>
		<category><![CDATA[errorString]]></category>
		<category><![CDATA[Hero]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=3323</guid>
		<description><![CDATA[<p>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.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/ --&#62; &#60;s:Application name=&#34;Spark_Form_Validator_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34;&#62; &#60;s:layout&#62; &#60;s:VerticalLayout horizontalAlign=&#34;center&#34; verticalAlign=&#34;middle&#34; /&#62; &#60;/s:layout&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; import mx.validators.Validator; &#160; protected function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can display the error indicator on a Spark FormItem container in Flex Hero by setting the <code>errorString</code> property or using the Flex validators.</p>
<p><span id="more-3323"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the beta Adobe Flex Hero SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex Hero SDK, see <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_Form_Validator_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.validators.Validator;</span>
&nbsp;
<span style="color: #000000;">            protected function resetBtn_clickHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                username.text = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                password1.text = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                password2.text = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                username.errorString = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">                password1.errorString = <span style="color: #ff0000;">&quot;&quot;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function submitBtn_clickHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                Validator.validateAll<span style="color: #66cc66;">&#40;</span>valArr<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Array</span> id=<span style="color: #ff0000;">&quot;valArr&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> source=<span style="color: #ff0000;">&quot;{username}&quot;</span> property=<span style="color: #ff0000;">&quot;text&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> minLength=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> source=<span style="color: #ff0000;">&quot;{password1}&quot;</span> property=<span style="color: #ff0000;">&quot;text&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span> minLength=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Array</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Form</span> id=<span style="color: #ff0000;">&quot;frm&quot;</span> defaultButton=<span style="color: #ff0000;">&quot;{submitBtn}&quot;</span> backgroundColor=<span style="color: #ff0000;">&quot;#EEEEEE&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormHeading</span> label=<span style="color: #ff0000;">&quot;Spark Form Heading&quot;</span> backgroundColor=<span style="color: #ff0000;">&quot;haloSilver&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span> sequenceLabel=<span style="color: #ff0000;">&quot;1.&quot;</span> label=<span style="color: #ff0000;">&quot;Username:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;user@domain.com&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span> sequenceLabel=<span style="color: #ff0000;">&quot;2.&quot;</span> label=<span style="color: #ff0000;">&quot;Password:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;weak&quot;</span> color=<span style="color: #ff0000;">&quot;red&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;password1&quot;</span> displayAsPassword=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span> sequenceLabel=<span style="color: #ff0000;">&quot;3.&quot;</span> label=<span style="color: #ff0000;">&quot;Confirm password:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;One&quot;</span> color=<span style="color: #ff0000;">&quot;red&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Label</span> text=<span style="color: #ff0000;">&quot;Two&quot;</span> color=<span style="color: #ff0000;">&quot;blue&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:HGroup</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:helpContent</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;password2&quot;</span> displayAsPassword=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;resetBtn&quot;</span> label=<span style="color: #ff0000;">&quot;Reset&quot;</span> click=<span style="color: #ff0000;">&quot;resetBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;submitBtn&quot;</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;submitBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">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.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Displaying the error indicator on a Spark FormItem container in Flex Hero on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/',contentID: 'post-3323',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'errorString,Hero,validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2010/08/30/displaying-the-error-indicator-on-a-spark-formitem-container-in-flex-hero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the AnimateColor effect to animate the content background color of a Spark TextInput control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/</link>
		<comments>http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 07:42:35 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Flex4]]></category>
		<category><![CDATA[TextInput (Spark)]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[contentBackgroundColor]]></category>
		<category><![CDATA[Gumbo]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/</guid>
		<description><![CDATA[<p>The following example shows how you can use the AnimateColor effect to animate the background color on a Spark TextInput control in Flex 4.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/ --&#62; &#60;s:Application name=&#34;Spark_TextInput_contentBackgroundColor_AnimateColor_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34; viewSourceURL=&#34;srcview/index.html&#34;&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; private function textInput_focusIn&#40;evt:FocusEvent&#41;:void &#123; colorEffect.play&#40;&#91;evt.currentTarget&#93;&#41;; &#125; &#160; private function textInput_focusOut&#40;evt:FocusEvent&#41;:void &#123; colorEffect.stop&#40;&#41;; evt.currentTarget.setStyle&#40;&#34;contentBackgroundColor&#34;, &#34;white&#34;&#41;; &#125; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use the AnimateColor effect to animate the background color on a Spark TextInput control in Flex 4.</p>
<p><span id="more-993"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_TextInput_contentBackgroundColor_AnimateColor_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> viewSourceURL=<span style="color: #ff0000;">&quot;srcview/index.html&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            private function textInput_focusIn<span style="color: #66cc66;">&#40;</span>evt:FocusEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                colorEffect.play<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>evt.currentTarget<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function textInput_focusOut<span style="color: #66cc66;">&#40;</span>evt:FocusEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                colorEffect.stop<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                evt.currentTarget.setStyle<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;contentBackgroundColor&quot;</span>, <span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:AnimateColor</span> id=<span style="color: #ff0000;">&quot;colorEffect&quot;</span></span>
<span style="color: #000000;">                colorPropertyName=<span style="color: #ff0000;">&quot;contentBackgroundColor&quot;</span></span>
<span style="color: #000000;">                colorFrom=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span></span>
<span style="color: #000000;">                colorTo=<span style="color: #ff0000;">&quot;0xFF0000&quot;</span></span>
<span style="color: #000000;">                repeatBehavior=<span style="color: #ff0000;">&quot;reverse&quot;</span></span>
<span style="color: #000000;">                repeatCount=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                duration=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textArea1&quot;</span></span>
<span style="color: #000000;">                text=<span style="color: #ff0000;">&quot;The quick brown fox jumps over the lazy dog.&quot;</span></span>
<span style="color: #000000;">                focusIn=<span style="color: #ff0000;">&quot;textInput_focusIn(event);&quot;</span></span>
<span style="color: #000000;">                focusOut=<span style="color: #ff0000;">&quot;textInput_focusOut(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textArea2&quot;</span></span>
<span style="color: #000000;">                text=<span style="color: #ff0000;">&quot;The quick brown fox jumps over the lazy dog.&quot;</span></span>
<span style="color: #000000;">                focusIn=<span style="color: #ff0000;">&quot;textInput_focusIn(event);&quot;</span></span>
<span style="color: #000000;">                focusOut=<span style="color: #ff0000;">&quot;textInput_focusOut(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textArea3&quot;</span></span>
<span style="color: #000000;">                text=<span style="color: #ff0000;">&quot;The quick brown fox jumps over the lazy dog.&quot;</span></span>
<span style="color: #000000;">                focusIn=<span style="color: #ff0000;">&quot;textInput_focusIn(event);&quot;</span></span>
<span style="color: #000000;">                focusOut=<span style="color: #ff0000;">&quot;textInput_focusOut(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_TextInput_contentBackgroundColor_AnimateColor_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_TextInput_contentBackgroundColor_AnimateColor_test/main.html" width="100%" height="150"></iframe></p>
<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p>You can also animate the content background color on a Spark TextInput control in Flex 4 by using validators, as seen in the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_TextInput_contentBackgroundColor_AnimateColor_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.controls.Alert;</span>
<span style="color: #000000;">            import mx.validators.Validator;</span>
<span style="color: #000000;">            import mx.events.ValidationResultEvent;</span>
&nbsp;
<span style="color: #000000;">            private function validateAll<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                colorEffect.stop<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                var results:Array = Validator.validateAll<span style="color: #66cc66;">&#40;</span>validatorArr<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>results.length == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    Alert.show<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;SUCCESS&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span> else <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    var targetArr:Array = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</span>
<span style="color: #000000;">                    var result:ValidationResultEvent;</span>
<span style="color: #000000;">                    for each <span style="color: #66cc66;">&#40;</span>result in results<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                        targetArr.push<span style="color: #66cc66;">&#40;</span>result.currentTarget.source<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                    <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">                    colorEffect.play<span style="color: #66cc66;">&#40;</span>targetArr<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function textInput_invalid<span style="color: #66cc66;">&#40;</span>trgt:Object<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                trgt.setStyle<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;contentBackgroundColor&quot;</span>, <span style="color: #ff0000;">&quot;red&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function textInput_valid<span style="color: #66cc66;">&#40;</span>trgt:Object<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                trgt.setStyle<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;contentBackgroundColor&quot;</span>, <span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:AnimateColor</span> id=<span style="color: #ff0000;">&quot;colorEffect&quot;</span></span>
<span style="color: #000000;">                colorPropertyName=<span style="color: #ff0000;">&quot;contentBackgroundColor&quot;</span></span>
<span style="color: #000000;">                colorFrom=<span style="color: #ff0000;">&quot;0xFFFFFF&quot;</span></span>
<span style="color: #000000;">                colorTo=<span style="color: #ff0000;">&quot;0xFF0000&quot;</span></span>
<span style="color: #000000;">                repeatBehavior=<span style="color: #ff0000;">&quot;reverse&quot;</span></span>
<span style="color: #000000;">                repeatCount=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                duration=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Array</span> id=<span style="color: #ff0000;">&quot;validatorArr&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;validator1&quot;</span></span>
<span style="color: #000000;">                    source=<span style="color: #ff0000;">&quot;{textInput1}&quot;</span></span>
<span style="color: #000000;">                    property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                    tooShortError=<span style="color: #ff0000;">&quot;This string is shorter than the minimum allowed length of 4.&quot;</span></span>
<span style="color: #000000;">                    tooLongError=<span style="color: #ff0000;">&quot;This string is longer than the maximum allowed length of 20.&quot;</span></span>
<span style="color: #000000;">                    minLength=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #000000;">                    maxLength=<span style="color: #ff0000;">&quot;20&quot;</span></span>
<span style="color: #000000;">                    valid=<span style="color: #ff0000;">&quot;textInput_valid(event.currentTarget.source);&quot;</span></span>
<span style="color: #000000;">                    invalid=<span style="color: #ff0000;">&quot;textInput_invalid(event.currentTarget.source);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;validator2&quot;</span></span>
<span style="color: #000000;">                    source=<span style="color: #ff0000;">&quot;{textInput2}&quot;</span></span>
<span style="color: #000000;">                    property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                    tooShortError=<span style="color: #ff0000;">&quot;This string is shorter than the minimum allowed length of 4.&quot;</span></span>
<span style="color: #000000;">                    tooLongError=<span style="color: #ff0000;">&quot;This string is longer than the maximum allowed length of 20.&quot;</span></span>
<span style="color: #000000;">                    minLength=<span style="color: #ff0000;">&quot;4&quot;</span></span>
<span style="color: #000000;">                    maxLength=<span style="color: #ff0000;">&quot;20&quot;</span></span>
<span style="color: #000000;">                    valid=<span style="color: #ff0000;">&quot;textInput_valid(event.currentTarget.source);&quot;</span></span>
<span style="color: #000000;">                    invalid=<span style="color: #ff0000;">&quot;textInput_invalid(event.currentTarget.source);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Array</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> id=<span style="color: #ff0000;">&quot;frm&quot;</span></span>
<span style="color: #000000;">             horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">             verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Username:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textInput1&quot;</span> maxChars=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Password:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textInput2&quot;</span> maxChars=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Email:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textInput3&quot;</span> maxChars=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> id=<span style="color: #ff0000;">&quot;btn&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;Validate!&quot;</span></span>
<span style="color: #000000;">                    click=<span style="color: #ff0000;">&quot;validateAll();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_TextInput_contentBackgroundColor_AnimateColor_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_TextInput_contentBackgroundColor_AnimateColor_test/main2.html" width="100%" height="300"></iframe></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using the AnimateColor effect to animate the content background color of a Spark TextInput control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/',contentID: 'post-993',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'contentBackgroundColor,Gumbo',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/03/06/using-the-fxanimatecolor-effect-to-animate-the-content-background-color-of-a-fxtextinput-control-in-flex-gumbo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Trimming strings using the Flex StringUtil class&#8217;s trim() method</title>
		<link>http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/</link>
		<comments>http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/#comments</comments>
		<pubDate>Fri, 07 Sep 2007 07:22:58 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[EmailValidator]]></category>
		<category><![CDATA[StringUtil]]></category>
		<category><![CDATA[StringValidator]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[.errorTip]]></category>
		<category><![CDATA[trim()]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/</guid>
		<description><![CDATA[<p>The following example shows you how to use the StringUtil.trim() method in Flex to remove leading and trailing whitespace from form fields before validating user input. This allows you to make sure that user&#8217;s don&#8217;t try anything sneaky like enter spaces instead of characters to bypass any minimum length validation you may have in place [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows you how to use the <code>StringUtil.trim()</code> method in Flex to remove leading and trailing whitespace from form fields before validating user input. This allows you to make sure that user&#8217;s don&#8217;t try anything sneaky like enter spaces instead of characters to bypass any minimum length validation you may have in place when validating data.</p>
<p>Full code after the jump.</p>
<p><span id="more-159"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;StringUtil_trim_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
        .errorTip {
            borderColor: haloBlue;
        }
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.controls.Alert;</span>
<span style="color: #339933;">            import mx.controls.TextInput;</span>
<span style="color: #339933;">            import mx.utils.StringUtil;</span>
<span style="color: #339933;">            import mx.validators.Validator;</span>
&nbsp;
<span style="color: #339933;">            private function trimStr(evt:FocusEvent):void {</span>
<span style="color: #339933;">                var ti:TextInput = TextInput(evt.currentTarget);</span>
<span style="color: #339933;">                ti.text = StringUtil.trim(ti.text);</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function validateForm():void {</span>
<span style="color: #339933;">                var errors:Array = Validator.validateAll(validatorArray);</span>
<span style="color: #339933;">                if (errors.length) {</span>
<span style="color: #339933;">                    Alert.show(&quot;Form is somehow invalid.&quot;, &quot;INVALID&quot;);</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    Alert.show(&quot;Form is valid.&quot;, &quot;VALID&quot;);</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Array</span> id=<span style="color: #ff0000;">&quot;validatorArray&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;firstNameValidator&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{firstName}&quot;</span></span>
<span style="color: #000000;">                property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                required=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:StringValidator</span> id=<span style="color: #ff0000;">&quot;lastNameValidator&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{lastName}&quot;</span></span>
<span style="color: #000000;">                property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                required=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:EmailValidator</span> id=<span style="color: #ff0000;">&quot;emailValidator&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{email}&quot;</span></span>
<span style="color: #000000;">                property=<span style="color: #ff0000;">&quot;text&quot;</span></span>
<span style="color: #000000;">                required=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Array</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;First name:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;firstName&quot;</span> focusOut=<span style="color: #ff0000;">&quot;trimStr(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Last name:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;lastName&quot;</span> focusOut=<span style="color: #ff0000;">&quot;trimStr(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Email:&quot;</span> required=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:TextInput</span> id=<span style="color: #ff0000;">&quot;email&quot;</span> focusOut=<span style="color: #ff0000;">&quot;trimStr(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Submit&quot;</span> click=<span style="color: #ff0000;">&quot;validateForm();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/StringUtil_trim_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/StringUtil_trim_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Trimming strings using the Flex StringUtil class\&#039;s trim() method on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/',contentID: 'post-159',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '.errorTip,trim(),validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Using the Validators.validateAll() method to validate a form</title>
		<link>http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/</link>
		<comments>http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 17:25:03 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[StringValidator]]></category>
		<category><![CDATA[Validator]]></category>
		<category><![CDATA[Validators]]></category>
		<category><![CDATA[enabled]]></category>
		<category><![CDATA[filter()]]></category>
		<category><![CDATA[validateAll()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/</guid>
		<description><![CDATA[<p>I recently saw this issue in FlexCoders and filed a bug for the poster. Well, it turns out the bug I filed was a duplicate of an existing bug, and that bug has been fixed (in Flex 3 &#8212; codename:Moxie). So, long story longer, here&#8217;s how you can use the Validator class&#8217;s validateAll() method to [...]]]></description>
			<content:encoded><![CDATA[<p>I recently saw this issue in FlexCoders and filed a bug for the poster. Well, it turns out the bug I filed was a duplicate of an existing bug, and that bug has been fixed (in Flex 3 &#8212; codename:Moxie). So, long story longer, here&#8217;s how you can use the Validator class&#8217;s <code>validateAll()</code> method to validate a form (which may or may not have enabled validators).</p>
<p>Full code (and workaround) after the jump.</p>
<p><span id="more-47"></span></p>
<p>This bug was reportedly fixed in build 176281, so if you have an older Flex 3 build, you may need to use the Flex 2 workaround below. Or, you could go to the <a href="http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html">nightly Flex 3 SDK builds page on the Adobe Labs site</a> and download a build newer than 176281, which is basically anything newer than Thursday July 12, 2007.</p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- FLEX 3 SOLUTION --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="initApp()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ValidationResultEvent;
            import mx.controls.Alert;
            import mx.validators.Validator;

            private var myValidators:Array;

            private function initApp():void {
                myValidators = [valid1, valid2];
            }

            private function clickHandler():void {
                var errors:Array = Validator.validateAll(myValidators);
                if (errors.length == 0) {
                    Alert.show("Looks valid to me.", "SUCCESS");
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:StringValidator id="valid1" source="{ti1}" property="text" minLength="4" maxLength="6" /&gt;
    &lt;mx:StringValidator id="valid2" source="{ti2}" property="text" minLength="4" maxLength="6" enabled="false" /&gt;

    &lt;mx:TextInput id="ti1" /&gt;
    &lt;mx:TextInput id="ti2" /&gt;

    &lt;mx:Button label="validate" click="clickHandler()" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>If you are using Flex 2.0.1 (Hotfix 2 or Hotfix 3), the easiest workaroud I&#8217;ve found is to just filter the array of validators that you pass to the <code>validateAll()</code> method so that no validators are passed if their <code>enabled</code> property is set to false. Thankfully this is pretty simple if you use the Array class&#8217;s <code>filter()</code> method, as seen below.</p>
<pre class="code" lang="actionscript">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- FLEX 2 SOLUTION --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="initApp()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ValidationResultEvent;
            import mx.controls.Alert;
            import mx.validators.Validator;

            private var myValidators:Array;

            private function initApp():void {
                myValidators = [valid1, valid2].filter(filterDisabledValidators);
            }

            private function clickHandler():void {
                var errors:Array = Validator.validateAll(myValidators);
                if (errors.length == 0) {
                    Alert.show("Looks valid to me.", "SUCCESS");
                }
            }

            private function filterDisabledValidators(element:*, index:int, arr:Array):Boolean {
                return element.enabled;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:StringValidator id="valid1" source="{ti1}" property="text" minLength="4" maxLength="6" /&gt;
    &lt;mx:StringValidator id="valid2" source="{ti2}" property="text" minLength="4" maxLength="6" enabled="false" /&gt;

    &lt;mx:TextInput id="ti1" /&gt;
    &lt;mx:TextInput id="ti2" /&gt;

    &lt;mx:Button label="validate" click="clickHandler()" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="note">For more information on the bug, and where I got the code for this post, see the bug in the public Flex bugbase at: <a href="http://bugs.adobe.com/jira/browse/SDK-9408">http://bugs.adobe.com/jira/browse/SDK-9408</a>.</p>
<p>Happy Flexing!</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using the Validators.validateAll() method to validate a form on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/',contentID: 'post-47',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'enabled,filter(),validateAll()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/08/02/using-the-validatorsvalidateall-method-to-validate-a-form/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

