<?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; setFocus()</title>
	<atom:link href="http://blog.flexexamples.com/tag/setfocus/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>Setting the focus alpha on a Spark TextArea control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/09/08/setting-the-focus-alpha-on-a-spark-textarea-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/09/08/setting-the-focus-alpha-on-a-spark-textarea-control-in-flex-4/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 13:30:19 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[TextArea (Spark)]]></category>
		<category><![CDATA[focusAlpha]]></category>
		<category><![CDATA[focusColor]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[setFocus()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=1839</guid>
		<description><![CDATA[<p>The following example shows how you can set the focus alpha on the Spark TextArea control in Flex 4 by setting the focusAlpha style.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2009/09/08/setting-the-focus-alpha-on-a-spark-textarea-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_TextArea_focusAlpha_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/halo&#34;&#62; &#60;s:controlBarContent&#62; &#60;mx:Form contentBackgroundAlpha=&#34;0&#34;&#62; &#60;mx:FormItem label=&#34;focusAlpha:&#34;&#62; &#60;s:HSlider id=&#34;slider&#34; minimum=&#34;0.0&#34; maximum=&#34;1.0&#34; value=&#34;0.8&#34; snapInterval=&#34;0.1&#34; stepSize=&#34;0.1&#34; change=&#34;txtArea.setFocus();&#34; /&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the focus alpha on the Spark TextArea control in Flex 4 by setting the <code>focusAlpha</code> style.</p>
<p>Full code after the jump.</p>
<p><span id="more-1839"></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/09/08/setting-the-focus-alpha-on-a-spark-textarea-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_TextArea_focusAlpha_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/halo&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> contentBackgroundAlpha=<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;focusAlpha:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HSlider</span> id=<span style="color: #ff0000;">&quot;slider&quot;</span></span>
<span style="color: #000000;">                        minimum=<span style="color: #ff0000;">&quot;0.0&quot;</span></span>
<span style="color: #000000;">                        maximum=<span style="color: #ff0000;">&quot;1.0&quot;</span></span>
<span style="color: #000000;">                        value=<span style="color: #ff0000;">&quot;0.8&quot;</span></span>
<span style="color: #000000;">                        snapInterval=<span style="color: #ff0000;">&quot;0.1&quot;</span></span>
<span style="color: #000000;">                        stepSize=<span style="color: #ff0000;">&quot;0.1&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;txtArea.setFocus();&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;focusColor:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ColorPicker</span> id=<span style="color: #ff0000;">&quot;colorPicker&quot;</span></span>
<span style="color: #000000;">                        selectedColor=<span style="color: #ff0000;">&quot;haloBlue&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;callLater(txtArea.setFocus);&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>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextArea</span> id=<span style="color: #ff0000;">&quot;txtArea&quot;</span></span>
<span style="color: #000000;">            focusAlpha=<span style="color: #ff0000;">&quot;{slider.value}&quot;</span></span>
<span style="color: #000000;">            focusColor=<span style="color: #ff0000;">&quot;{colorPicker.selectedColor}&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">            creationComplete=<span style="color: #ff0000;">&quot;txtArea.setFocus();&quot;</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 4 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 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the focus alpha on a Spark TextArea control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/09/08/setting-the-focus-alpha-on-a-spark-textarea-control-in-flex-4/',contentID: 'post-1839',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'focusAlpha,focusColor,Gumbo,setFocus()',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/09/08/setting-the-focus-alpha-on-a-spark-textarea-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a simple text editor using the Spark TextArea control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/07/24/creating-a-simple-text-editor-using-the-spark-textarea-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/07/24/creating-a-simple-text-editor-using-the-spark-textarea-control-in-flex-4/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:43:36 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[TextArea (Spark)]]></category>
		<category><![CDATA[TextFlow]]></category>
		<category><![CDATA[TextLayoutFormat]]></category>
		<category><![CDATA[getFormatOfRange()]]></category>
		<category><![CDATA[selectionActivePosition]]></category>
		<category><![CDATA[selectionAnchorPosition]]></category>
		<category><![CDATA[setFocus()]]></category>
		<category><![CDATA[setFormatOfRange()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=1237</guid>
		<description><![CDATA[<p>The following example shows how you can create a simple rich text editor control in Flex 4 using the Spark TextArea control and using the getFormatOfRange() and setFormatOfRange() methods.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2009/07/24/creating-a-simple-text-editor-using-the-spark-textarea-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_TextArea_setFormatOfRange_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/halo&#34;&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; import flash.text.engine.FontPosture; import flash.text.engine.FontWeight; import flashx.textLayout.formats.TextAlign; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create a simple rich text editor control in Flex 4 using the Spark TextArea control and using the <code>getFormatOfRange()</code> and <code>setFormatOfRange()</code> methods.</p>
<p>Full code after the jump.</p>
<p><span id="more-1237"></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/07/24/creating-a-simple-text-editor-using-the-spark-textarea-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_TextArea_setFormatOfRange_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/halo&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 flash.text.engine.FontPosture;</span>
<span style="color: #000000;">            import flash.text.engine.FontWeight;</span>
<span style="color: #000000;">            import flashx.textLayout.formats.TextAlign;</span>
<span style="color: #000000;">            import flashx.textLayout.formats.TextDecoration;</span>
<span style="color: #000000;">            import flashx.textLayout.formats.TextLayoutFormat;</span>
<span style="color: #000000;">            import mx.events.ColorPickerEvent;</span>
<span style="color: #000000;">            import mx.events.FlexEvent;</span>
<span style="color: #000000;">            import spark.events.IndexChangeEvent;</span>
&nbsp;
<span style="color: #000000;">            protected function editor_selectionChangeHandler<span style="color: #66cc66;">&#40;</span>evt:FlexEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                fontDDL.selectedItem = txtLayFmt.fontFamily;</span>
<span style="color: #000000;">                sizeDDL.selectedItem = txtLayFmt.fontSize;</span>
<span style="color: #000000;">                boldBtn.selected = <span style="color: #66cc66;">&#40;</span>txtLayFmt.fontWeight == FontWeight.BOLD<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                italBtn.selected = <span style="color: #66cc66;">&#40;</span>txtLayFmt.fontStyle == FontPosture.ITALIC<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                underBtn.selected = <span style="color: #66cc66;">&#40;</span>txtLayFmt.textDecoration == TextDecoration.UNDERLINE<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                colorCP.selectedColor = txtLayFmt.color;</span>
<span style="color: #000000;">                lineBtn.selected = txtLayFmt.lineThrough;</span>
&nbsp;
<span style="color: #000000;">                switch <span style="color: #66cc66;">&#40;</span>txtLayFmt.textAlign<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    case TextAlign.LEFT:</span>
<span style="color: #000000;">                        txtAlignBB.selectedIndex = <span style="color: #cc66cc;">0</span>;</span>
<span style="color: #000000;">                        break;</span>
<span style="color: #000000;">                    case TextAlign.CENTER:</span>
<span style="color: #000000;">                        txtAlignBB.selectedIndex = <span style="color: #cc66cc;">1</span>;</span>
<span style="color: #000000;">                        break;</span>
<span style="color: #000000;">                    case TextAlign.RIGHT:</span>
<span style="color: #000000;">                        txtAlignBB.selectedIndex = <span style="color: #cc66cc;">2</span>;</span>
<span style="color: #000000;">                        break;</span>
<span style="color: #000000;">                    case TextAlign.JUSTIFY:</span>
<span style="color: #000000;">                        txtAlignBB.selectedIndex = <span style="color: #cc66cc;">3</span>;</span>
<span style="color: #000000;">                        break;</span>
<span style="color: #000000;">                    default:</span>
<span style="color: #000000;">                        txtAlignBB.selectedIndex = -<span style="color: #cc66cc;">1</span>;</span>
<span style="color: #000000;">                        break;</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;">            protected function fontDDL_changeHandler<span style="color: #66cc66;">&#40;</span>evt:IndexChangeEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.fontFamily = fontDDL.selectedItem;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function sizeDDL_changeHandler<span style="color: #66cc66;">&#40;</span>evt:IndexChangeEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.fontSize = sizeDDL.selectedItem;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function boldBtn_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;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.fontWeight = <span style="color: #66cc66;">&#40;</span>txtLayFmt.fontWeight == FontWeight.BOLD<span style="color: #66cc66;">&#41;</span> ? FontWeight.NORMAL : FontWeight.BOLD;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function italBtn_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;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.fontStyle = <span style="color: #66cc66;">&#40;</span>txtLayFmt.fontStyle == FontPosture.ITALIC<span style="color: #66cc66;">&#41;</span> ? FontPosture.NORMAL : FontPosture.ITALIC;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function underBtn_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;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.textDecoration = <span style="color: #66cc66;">&#40;</span>txtLayFmt.textDecoration == TextDecoration.UNDERLINE<span style="color: #66cc66;">&#41;</span> ? TextDecoration.NONE : TextDecoration.UNDERLINE;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function colorCP_changeHandler<span style="color: #66cc66;">&#40;</span>evt:ColorPickerEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.color = colorCP.selectedColor;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function txtAlignBB_changeHandler<span style="color: #66cc66;">&#40;</span>evt:IndexChangeEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>txtAlignBB.selectedItem<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                    editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                    editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                    txtLayFmt.textAlign = txtAlignBB.selectedItem.value;</span>
<span style="color: #000000;">                    editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                    editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                    editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                    editor.setFocus<span style="color: #66cc66;">&#40;</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;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function lineBtn_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;">                var txtLayFmt:TextLayoutFormat = editor.getFormatOfRange<span style="color: #66cc66;">&#40;</span>null,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                txtLayFmt.lineThrough = lineBtn.selected;</span>
<span style="color: #000000;">                editor.setFormatOfRange<span style="color: #66cc66;">&#40;</span>txtLayFmt,</span>
<span style="color: #000000;">                                editor.selectionAnchorPosition,</span>
<span style="color: #000000;">                                editor.selectionActivePosition<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                editor.setFocus<span style="color: #66cc66;">&#40;</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;s:Panel</span> title=<span style="color: #ff0000;">&quot;SimpleTextEditor&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;400&quot;</span></span>
<span style="color: #000000;">            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:layout</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> gap=<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:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextArea</span> id=<span style="color: #ff0000;">&quot;editor&quot;</span></span>
<span style="color: #000000;">                focusEnabled=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #000000;">                width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">                minHeight=<span style="color: #ff0000;">&quot;200&quot;</span></span>
<span style="color: #000000;">                selectionChange=<span style="color: #ff0000;">&quot;editor_selectionChangeHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:textFlow</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextFlow</span> paragraphSpaceBefore=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et nibh lorem. Nulla ut velit magna. Nunc quis libero ac orci porta tincidunt eget in lorem. Aenean vitae nisi vitae urna lacinia congue. Duis nec leo turpis. Phasellus dui orci, lacinia in dictum lacinia, ullamcorper a tortor. Suspendisse lacinia, turpis vel euismod gravida, turpis dui vulputate libero, vel consequat enim sem nec mauris. Curabitur vitae magna vel neque accumsan commodo vitae quis ipsum. Nullam ac condimentum elit. Integer eget magna ac mi fermentum luctus. Ut pharetra auctor pulvinar. Duis lobortis, nulla at vestibulum tincidunt, ante neque scelerisque risus, ac dignissim nunc nisl rhoncus risus. Cras pretium egestas purus, a commodo nunc vehicula at. Fusce vestibulum enim in mi hendrerit a viverra justo tempor. Maecenas eget ipsum ac mauris dictum congue eu id justo.<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>Aliquam tincidunt tempor nisi id porta. Aenean risus dolor, tincidunt a ultrices in, laoreet eu ante. Mauris vel lacus neque, ut scelerisque eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec vel lacus sit amet erat vehicula malesuada id in augue. Sed purus massa, placerat non imperdiet nec, venenatis a nulla. Donec vel ligula leo, in rhoncus arcu. Duis semper bibendum facilisis. Duis nibh lorem, egestas rutrum tincidunt non, vulputate accumsan nulla. Nunc ligula nisl, ultrices ut tempor quis, rutrum et enim. Nullam accumsan scelerisque ante id pretium. Mauris nibh metus, blandit in varius congue, pharetra sit amet sem. Phasellus tincidunt lacus quis est semper ut rhoncus sem pretium. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pulvinar, enim eu consectetur venenatis, dui tortor commodo ante, sit amet sagittis libero odio cursus neque. Aliquam a dui non eros placerat euismod. In at mattis felis. Suspendisse potenti. Morbi posuere condimentum lacus. Suspendisse tellus magna, viverra ac mattis vel, adipiscing eget lectus.<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>Etiam ut eros lectus. Praesent nec massa nibh. Cras venenatis, ligula in condimentum euismod, nisl lorem hendrerit lacus, a imperdiet odio est et odio. Suspendisse eu orci ut augue commodo gravida sed eu risus. Vestibulum venenatis erat ac metus ullamcorper blandit. Integer et sem enim. Vivamus a arcu metus. Nunc sollicitudin commodo placerat. Maecenas vehicula, massa et auctor tempor, felis leo commodo lorem, eget pulvinar felis turpis nec erat. Mauris imperdiet gravida felis a eleifend.<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>Suspendisse mattis tempor fringilla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed molestie arcu. Praesent ut tellus sed orci blandit tristique non eget est. Sed interdum feugiat nisi, sit amet aliquet enim sodales non. Maecenas in velit sit amet tellus tincidunt dapibus. Vivamus est eros, iaculis et venenatis a, malesuada vel lacus. Aliquam vel orci tortor. Etiam ornare ante eget massa dignissim a auctor nunc pellentesque. Pellentesque sodales porta nisi, pretium accumsan eros tincidunt vitae. Cras facilisis accumsan purus ultricies lacinia. Praesent consequat elit imperdiet tellus vehicula ut ornare mauris mattis. Suspendisse non tortor nisl. Etiam ac pretium est.<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:p</span><span style="color: #7400FF;">&gt;</span></span>Maecenas tristique, velit aliquam faucibus ornare, justo erat porta elit, sed venenatis neque mi ac elit. Nullam enim metus, gravida ac euismod sit amet, commodo vitae elit. Quisque eget molestie ante. Nulla fermentum pretium augue non tristique. Praesent in orci eu diam ultrices sodales ac quis leo. Aliquam lobortis elit quis mi rutrum feugiat. Aenean sed elit turpis. Duis enim ligula, posuere sit amet semper a, pretium vel leo. Etiam mollis dolor nec elit suscipit imperdiet. Sed a est eros.<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:p</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:TextFlow</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:textFlow</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:TextArea</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ControlBar</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> cornerRadius=<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:ToolBar</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> horizontalGap=<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:DropDownList</span> id=<span style="color: #ff0000;">&quot;fontDDL&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;150&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;fontDDL_changeHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span> source=<span style="color: #ff0000;">&quot;[Arial,Verdana,Times New Roman,Trebuchet MS]&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:DropDownList</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:DropDownList</span> id=<span style="color: #ff0000;">&quot;sizeDDL&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;60&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;sizeDDL_changeHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span> source=<span style="color: #ff0000;">&quot;[8,10,12,14,16,24,36,72]&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:DropDownList</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ToggleButton</span> id=<span style="color: #ff0000;">&quot;boldBtn&quot;</span></span>
<span style="color: #000000;">                        label=<span style="color: #ff0000;">&quot;B&quot;</span></span>
<span style="color: #000000;">                        fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;30&quot;</span></span>
<span style="color: #000000;">                        click=<span style="color: #ff0000;">&quot;boldBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ToggleButton</span> id=<span style="color: #ff0000;">&quot;italBtn&quot;</span></span>
<span style="color: #000000;">                        label=<span style="color: #ff0000;">&quot;I&quot;</span></span>
<span style="color: #000000;">                        fontStyle=<span style="color: #ff0000;">&quot;italic&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;30&quot;</span></span>
<span style="color: #000000;">                        click=<span style="color: #ff0000;">&quot;italBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ToggleButton</span> id=<span style="color: #ff0000;">&quot;underBtn&quot;</span></span>
<span style="color: #000000;">                        label=<span style="color: #ff0000;">&quot;U&quot;</span> </span>
<span style="color: #000000;">                        textDecoration=<span style="color: #ff0000;">&quot;underline&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;30&quot;</span></span>
<span style="color: #000000;">                        click=<span style="color: #ff0000;">&quot;underBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ToggleButton</span> id=<span style="color: #ff0000;">&quot;lineBtn&quot;</span></span>
<span style="color: #000000;">                        label=<span style="color: #ff0000;">&quot;S&quot;</span></span>
<span style="color: #000000;">                        lineThrough=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;30&quot;</span></span>
<span style="color: #000000;">                        click=<span style="color: #ff0000;">&quot;lineBtn_clickHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ColorPicker</span> id=<span style="color: #ff0000;">&quot;colorCP&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;colorCP_changeHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ButtonBar</span> id=<span style="color: #ff0000;">&quot;txtAlignBB&quot;</span></span>
<span style="color: #000000;">                        arrowKeysWrapFocus=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">                        labelField=<span style="color: #ff0000;">&quot;label&quot;</span></span>
<span style="color: #000000;">                        width=<span style="color: #ff0000;">&quot;120&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;txtAlignBB_changeHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ArrayList</span><span style="color: #7400FF;">&gt;</span></span>
                            <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> label=<span style="color: #ff0000;">&quot;L&quot;</span> value=<span style="color: #ff0000;">&quot;{TextAlign.LEFT}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                            <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> label=<span style="color: #ff0000;">&quot;C&quot;</span> value=<span style="color: #ff0000;">&quot;{TextAlign.CENTER}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                            <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> label=<span style="color: #ff0000;">&quot;R&quot;</span> value=<span style="color: #ff0000;">&quot;{TextAlign.RIGHT}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                            <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> label=<span style="color: #ff0000;">&quot;J&quot;</span> value=<span style="color: #ff0000;">&quot;{TextAlign.JUSTIFY}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ArrayList</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ButtonBar</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ToolBar</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ControlBar</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</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://blog.flexexamples.com/wp-content/uploads/spark/Spark_TextArea_setFormatOfRange_test/bin/srcview/">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/spark/Spark_TextArea_setFormatOfRange_test/bin/main.html" width="100%" height="400"></iframe></p>
<p class="alert">This entry is based on a beta version of the Flex 4 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 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a simple text editor using the Spark TextArea control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/07/24/creating-a-simple-text-editor-using-the-spark-textarea-control-in-flex-4/',contentID: 'post-1237',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getFormatOfRange(),selectionActivePosition,selectionAnchorPosition,setFocus(),setFormatOfRange()',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/07/24/creating-a-simple-text-editor-using-the-spark-textarea-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Setting the focus blend mode on a TextArea control in Flex</title>
		<link>http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 07:18:21 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[TextArea]]></category>
		<category><![CDATA[blendMode]]></category>
		<category><![CDATA[focusBlendMode]]></category>
		<category><![CDATA[focusThickness]]></category>
		<category><![CDATA[setFocus()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the focus blend mode of the focus rectangle on a Flex TextArea control by setting the focusBlendMode style.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TextArea_focusBlendMode_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/ --&#62; &#60;mx:Application name="TextArea_focusBlendMode_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle"&#62; &#60;mx:ApplicationControlBar dock="true" styleName="plain"&#62; &#60;mx:Form styleName="plain"&#62; &#60;mx:FormItem label="focusThickness:"&#62; &#60;mx:HSlider [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the focus blend mode of the focus rectangle on a Flex TextArea control by setting the <code>focusBlendMode</code> style.</p>
<p>Full code after the jump.</p>
<p><span id="more-934"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TextArea_focusBlendMode_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/ --&gt;
&lt;mx:Application name="TextArea_focusBlendMode_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"&gt;

    &lt;mx:ApplicationControlBar dock="true" styleName="plain"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="focusThickness:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="0"
                        maximum="24"
                        value="10"
                        snapInterval="1"
                        tickInterval="1"
                        change="textArea.setFocus();" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="focusBlendMode:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        selectedIndex="10"
                        change="textArea.setFocus();"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:String&gt;{BlendMode.ADD}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.ALPHA}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.DARKEN}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.DIFFERENCE}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.ERASE}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.HARDLIGHT}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.INVERT}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.LAYER}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.LIGHTEN}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.MULTIPLY}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.NORMAL}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.OVERLAY}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.SCREEN}&lt;/mx:String&gt;
                            &lt;!--
                            &lt;mx:String&gt;{BlendMode.SHADER}&lt;/mx:String&gt;
                            --&gt;
                            &lt;mx:String&gt;{BlendMode.SUBTRACT}&lt;/mx:String&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ComboBox&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TextArea id="textArea"
            text="The quick brown fox jumps over the lazy dog."
            focusThickness="{slider.value}"
            focusBlendMode="{comboBox.selectedItem}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/TextArea_focusBlendMode_test/bin/srcview/">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/TextArea_focusBlendMode_test/bin/main.html" width="100%" height="250"></iframe></p>
<p>You can also set the <code>focusBlendMode</code> style in an external .CSS file or &lt;Style&gt; block, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TextArea_focusBlendMode_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/ --&gt;
&lt;mx:Application name="TextArea_focusBlendMode_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"&gt;

    &lt;mx:Style&gt;
        TextArea {
            focusThickness: 20;
            focusBlendMode: difference;
        }
    &lt;/mx:Style&gt;

    &lt;mx:TextArea id="textArea"
            text="The quick brown fox jumps over the lazy dog."  /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Or, you can set the <code>focusBlendMode</code> style using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/TextArea_focusBlendMode_test/bin/srcview/source/main3.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/ --&gt;
&lt;mx:Application name="TextArea_focusBlendMode_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ListEvent;
            import mx.events.SliderEvent;

            private function slider_change(evt:SliderEvent):void {
                textArea.setStyle("focusThickness", evt.value);
                textArea.setFocus();
            }

            private function comboBox_change(evt:ListEvent):void {
                textArea.setStyle("focusBlendMode", comboBox.selectedItem);
                textArea.setFocus();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true" styleName="plain"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="focusThickness:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="0"
                        maximum="24"
                        value="10"
                        snapInterval="1"
                        tickInterval="1"
                        change="slider_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="focusBlendMode:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        selectedIndex="10"
                        change="comboBox_change(event);"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:String&gt;{BlendMode.ADD}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.ALPHA}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.DARKEN}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.DIFFERENCE}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.ERASE}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.HARDLIGHT}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.INVERT}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.LAYER}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.LIGHTEN}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.MULTIPLY}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.NORMAL}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.OVERLAY}&lt;/mx:String&gt;
                            &lt;mx:String&gt;{BlendMode.SCREEN}&lt;/mx:String&gt;
                            &lt;!--
                            &lt;mx:String&gt;{BlendMode.SHADER}&lt;/mx:String&gt;
                            --&gt;
                            &lt;mx:String&gt;{BlendMode.SUBTRACT}&lt;/mx:String&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ComboBox&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TextArea id="textArea"
            text="The quick brown fox jumps over the lazy dog." /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the focus blend mode on a TextArea control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/',contentID: 'post-934',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'blendMode,focusBlendMode,focusThickness,setFocus()',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/01/11/setting-the-focus-blend-mode-on-a-textarea-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setting focus in Flex using the Focus Manager</title>
		<link>http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/</link>
		<comments>http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 05:42:00 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[FocusManager]]></category>
		<category><![CDATA[getFocus()]]></category>
		<category><![CDATA[setFocus()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/</guid>
		<description><![CDATA[<p>The following example shows how you can set focus on a TextInput control in Flex by using the Flex FocusManager class and the setFocus() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/FocusManager_setFocus_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/ --&#62; &#60;mx:Application name="FocusManager_setFocus_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; private function submitButton_click(evt:MouseEvent):void { [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set focus on a TextInput control in Flex by using the Flex FocusManager class and the <code>setFocus()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-804"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/FocusManager_setFocus_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/ --&gt;
&lt;mx:Application name="FocusManager_setFocus_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            private function submitButton_click(evt:MouseEvent):void {
                Alert.show(evt.currentTarget.label,
                            Object(focusManager.getFocus()).name);
            }

            private function resetButton_click(evt:MouseEvent):void {
                username.text = "";
                password.text = "";
                Alert.show(evt.currentTarget.label,
                            Object(focusManager.getFocus()).name);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Set focus to Username"
                click="focusManager.setFocus(username);" /&gt;
        &lt;mx:Button label="Set focus to Password"
                click="focusManager.setFocus(password);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Form id="form"
            defaultButton="{submitButton}"&gt;
        &lt;mx:FormItem label="Username:"&gt;
            &lt;mx:TextInput id="username" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem label="Password:"&gt;
            &lt;mx:TextInput id="password"
                    displayAsPassword="true" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem direction="horizontal"
                horizontalAlign="right"
                width="100%"&gt;
            &lt;mx:Button id="submitButton"
                    label="Submit"
                    click="submitButton_click(event);" /&gt;
            &lt;mx:Button id="resetButton"
                    label="Reset"
                    click="resetButton_click(event);" /&gt;
        &lt;/mx:FormItem&gt;
    &lt;/mx:Form&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/FocusManager_setFocus_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/FocusManager_setFocus_test/bin/main.html" width="100%" height="250"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/FocusManager_setFocus_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/ --&gt;
&lt;mx:Application name="FocusManager_setFocus_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.containers.FormItemDirection;
            import mx.controls.Alert;
            import mx.controls.Button;
            import mx.controls.TextInput;

            private var usernameButton:Button;
            private var passwordButton:Button;
            private var username:TextInput;
            private var password:TextInput;
            private var submitButton:Button;
            private var resetButton:Button;

            private function init():void {
                usernameButton = new Button();
                usernameButton.label = "Set focus to Username";
                usernameButton.addEventListener(MouseEvent.CLICK,
                            usernameButton_click);

                passwordButton = new Button();
                passwordButton.label = "Set focus to Password";
                passwordButton.addEventListener(MouseEvent.CLICK,
                            passwordButton_click);

                var appControlBar:ApplicationControlBar;
                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(usernameButton);
                appControlBar.addChild(passwordButton);
                addChildAt(appControlBar, 0);

                username = new TextInput();
                username.name = "username";

                password = new TextInput();
                password.displayAsPassword = true;
                password.name = "password";

                submitButton = new Button();
                submitButton.label = "Submit";
                submitButton.name = "submitButton";
                submitButton.addEventListener(MouseEvent.CLICK,
                            submitButton_click);

                resetButton = new Button();
                resetButton.label = "Reset";
                resetButton.name = "resetButton";
                resetButton.addEventListener(MouseEvent.CLICK,
                            resetButton_click);

                var formItem1:FormItem = new FormItem();
                formItem1.label = "Username:";
                formItem1.addChild(username);

                var formItem2:FormItem = new FormItem();
                formItem2.label = "Password:";
                formItem2.addChild(password);

                var formItem3:FormItem = new FormItem();
                formItem3.direction = FormItemDirection.HORIZONTAL;
                formItem3.setStyle("horizontalAlign", "right");
                formItem3.percentWidth = 100;
                formItem3.addChild(submitButton);
                formItem3.addChild(resetButton);

                var form:Form = new Form();
                form.defaultButton = submitButton;
                form.addChild(formItem1);
                form.addChild(formItem2);
                form.addChild(formItem3);
                addChild(form);
            }

            private function usernameButton_click(evt:MouseEvent):void {
                focusManager.setFocus(username);
            }

            private function passwordButton_click(evt:MouseEvent):void {
                focusManager.setFocus(password);
            }

            private function submitButton_click(evt:MouseEvent):void {
                Alert.show(evt.currentTarget.label,
                            Object(focusManager.getFocus()).name);
            }

            private function resetButton_click(evt:MouseEvent):void {
                username.text = "";
                password.text = "";
                Alert.show(evt.currentTarget.label,
                            Object(focusManager.getFocus()).name);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting focus in Flex using the Focus Manager on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/23/setting-focus-in-flex-using-the-focus-manager/',contentID: 'post-804',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getFocus(),setFocus()',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/2008/09/23/setting-focus-in-flex-using-the-focus-manager/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Setting the focus alpha on a NumericStepper control in Flex</title>
		<link>http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/#comments</comments>
		<pubDate>Sat, 24 May 2008 06:27:53 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[FocusManager]]></category>
		<category><![CDATA[NumericStepper]]></category>
		<category><![CDATA[focusAlpha]]></category>
		<category><![CDATA[setFocus()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the focus alpha on a Flex NumericStepper control by setting the focusAlpha style.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/NumericStepper_focusAlpha_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.events.NumericStepperEvent; private function numericStepper_change(evt:NumericStepperEvent):void { // reset focus focusManager.setFocus(btn); focusManager.setFocus(numericStepper); [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the focus alpha on a Flex NumericStepper control by setting the <code>focusAlpha</code> style.</p>
<p>Full code after the jump.</p>
<p><span id="more-641"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/NumericStepper_focusAlpha_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.NumericStepperEvent;

            private function numericStepper_change(evt:NumericStepperEvent):void {
                // reset focus
                focusManager.setFocus(btn);
                focusManager.setFocus(numericStepper);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="btn" label="click here to remove focus" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:NumericStepper id="numericStepper"
            minimum="0.0"
            maximum="1.0"
            value="0.5"
            stepSize="0.1"
            textAlign="center"
            focusAlpha="{numericStepper.value}"
            change="numericStepper_change(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/NumericStepper_focusAlpha_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/NumericStepper_focusAlpha_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>You can also set the <code>focusAlpha</code> style in an external .CSS file or &lt;mx:Style /&gt; block, as shown in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/NumericStepper_focusAlpha_test/bin/srcview/source/main1.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        NumericStepper {
            focusAlpha: 1.0;
        }
    &lt;/mx:Style&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="btn" label="click here to remove focus" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:NumericStepper id="numericStepper"
            minimum="0.0"
            maximum="1.0"
            value="1.0"
            stepSize="0.1"
            textAlign="center"/&gt;

&lt;/mx:Application&gt;
</pre>
<p>Or you can set the <code>focusAlpha</code> style using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/NumericStepper_focusAlpha_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.NumericStepperEvent;

            private function numericStepper_change(evt:NumericStepperEvent):void {
                numericStepper.setStyle("focusAlpha", evt.value);
                // reset focus
                focusManager.setFocus(btn);
                focusManager.setFocus(numericStepper);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="btn" label="click here to remove focus" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:NumericStepper id="numericStepper"
            minimum="0.0"
            maximum="1.0"
            value="0.5"
            stepSize="0.1"
            textAlign="center"
            change="numericStepper_change(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the focus alpha on a NumericStepper control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/',contentID: 'post-641',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'focusAlpha,setFocus()',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/2008/05/23/setting-the-focus-alpha-on-a-numericstepper-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

