<?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; preventDefault()</title>
	<atom:link href="http://blog.flexexamples.com/tag/preventdefault/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>Preventing item selection in the Spark List control in Flex 4</title>
		<link>http://blog.flexexamples.com/2010/02/25/preventing-item-selection-in-the-spark-list-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2010/02/25/preventing-item-selection-in-the-spark-list-control-in-flex-4/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 19:28:14 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[List (Spark)]]></category>
		<category><![CDATA[changing]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[preventDefault()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2523</guid>
		<description><![CDATA[<p>The following example shows how you can prevent item selection in the Spark List control in Flex 4 by listening for the changing event and calling the preventDefault() method on the IndexChangeEvent event object instance.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/02/25/preventing-item-selection-in-the-spark-list-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_List_changing_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; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; import spark.events.IndexChangeEvent; &#160; protected function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can prevent item selection in the Spark List control in Flex 4 by listening for the <code>changing</code> event and calling the <code>preventDefault()</code> method on the IndexChangeEvent event object instance.</p>
<p><span id="more-2523"></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/2010/02/25/preventing-item-selection-in-the-spark-list-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_List_changing_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 spark.events.IndexChangeEvent;</span>
&nbsp;
<span style="color: #000000;">            protected function lst_changingHandler<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;">                evt.preventDefault<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:controlBarContent</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;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;selectedIndex:&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;{lst.selectedIndex}&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:List</span> id=<span style="color: #ff0000;">&quot;lst&quot;</span></span>
<span style="color: #000000;">            changing=<span style="color: #ff0000;">&quot;lst_changingHandler(event);&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> horizontalAlign=<span style="color: #ff0000;">&quot;justify&quot;</span></span>
<span style="color: #000000;">                              gap=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                              requestedRowCount=<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:layout</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;[The,Quick,Brown,Fox,Jumps,Over,The,Lazy,Dog]&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:List</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>

<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 class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_List_changing_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_List_changing_test/main.html" width="100%" height="300"></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: 'Preventing item selection in the Spark List control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/02/25/preventing-item-selection-in-the-spark-list-control-in-flex-4/',contentID: 'post-2523',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'changing,Gumbo,preventDefault()',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/02/25/preventing-item-selection-in-the-spark-list-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Creating a non-draggable Spark TitleWindow container in Flex 4</title>
		<link>http://blog.flexexamples.com/2010/01/19/creating-a-non-draggable-spark-titlewindow-container-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2010/01/19/creating-a-non-draggable-spark-titlewindow-container-in-flex-4/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 19:52:46 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[TitleWindow (Spark)]]></category>
		<category><![CDATA[moveArea]]></category>
		<category><![CDATA[preventDefault()]]></category>
		<category><![CDATA[stopImmediatePropagation()]]></category>
		<category><![CDATA[windowMoving]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2296</guid>
		<description><![CDATA[<p>The following example shows how you can create a non-draggable Spark TitleWindow container in Flex 4 by listening for the windowMoving event and calling the stopImmediatePropagation() and preventDefault() 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/2010/01/19/creating-a-non-draggable-spark-titlewindow-container-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_TitleWindow_windowMoving_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:controlBarContent&#62; &#60;s:Button id=&#34;btn&#34; label=&#34;launch Spark TitleWindow&#34; click=&#34;btn_clickHandler(event);&#34; /&#62; &#60;/s:controlBarContent&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create a non-draggable Spark TitleWindow container in Flex 4 by listening for the <code>windowMoving</code> event and calling the <code>stopImmediatePropagation()</code> and <code>preventDefault()</code> methods.</p>
<p>Full code after the jump.</p>
<p><span id="more-2296"></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/2010/01/19/creating-a-non-draggable-spark-titlewindow-container-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_TitleWindow_windowMoving_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:controlBarContent</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;launch Spark TitleWindow&quot;</span></span>
<span style="color: #000000;">                click=<span style="color: #ff0000;">&quot;btn_clickHandler(event);&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>
&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.core.IFlexDisplayObject;</span>
<span style="color: #000000;">            import mx.events.CloseEvent;</span>
<span style="color: #000000;">            import mx.managers.PopUpManager;</span>
<span style="color: #000000;">            import spark.events.TitleWindowBoundsEvent;</span>
&nbsp;
<span style="color: #000000;">            protected function btn_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;">                // Add and center the pop up window.</span>
<span style="color: #000000;">                PopUpManager.addPopUp<span style="color: #66cc66;">&#40;</span>titleWin, this, true<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                PopUpManager.centerPopUp<span style="color: #66cc66;">&#40;</span>titleWin<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 titleWin_closeHandler<span style="color: #66cc66;">&#40;</span>evt:CloseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                // Remove the pop up window.</span>
<span style="color: #000000;">                PopUpManager.removePopUp<span style="color: #66cc66;">&#40;</span>evt.currentTarget as IFlexDisplayObject<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 titleWin_windowMovingHandler<span style="color: #66cc66;">&#40;</span>evt:TitleWindowBoundsEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                // Before moving the TitleWindow container, check to see whether it should be draggable.</span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>!ch.selected<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    evt.stopImmediatePropagation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                    evt.preventDefault<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>
<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:TitleWindow</span> id=<span style="color: #ff0000;">&quot;titleWin&quot;</span></span>
<span style="color: #000000;">                title=<span style="color: #ff0000;">&quot;Spark TitleWindow container&quot;</span></span>
<span style="color: #000000;">                width=<span style="color: #ff0000;">&quot;240&quot;</span></span>
<span style="color: #000000;">                close=<span style="color: #ff0000;">&quot;titleWin_closeHandler(event);&quot;</span></span>
<span style="color: #000000;">                windowMoving=<span style="color: #ff0000;">&quot;titleWin_windowMovingHandler(event);&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> paddingLeft=<span style="color: #ff0000;">&quot;10&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #000000;">                        paddingTop=<span style="color: #ff0000;">&quot;10&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;10&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:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CheckBox</span> id=<span style="color: #ff0000;">&quot;ch&quot;</span></span>
<span style="color: #000000;">                        label=<span style="color: #ff0000;">&quot;Should I be draggable?&quot;</span></span>
<span style="color: #000000;">                        selected=<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:controlBarContent</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;The quick brown fox jumps over the lazy dog.&quot;</span></span>
<span style="color: #000000;">                    width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:TitleWindow</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:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="new">And a big thanks to my co-worker Kevin Lin for the following tip. You can also toggle a Spark TitleWindow container&#8217;s dragability by setting the <code>moveArea</code> skin part&#8217;s Boolean <code>visible</code> property, 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/2010/01/19/creating-a-non-draggable-spark-titlewindow-container-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_TitleWindow_moveArea_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:controlBarContent</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;launch Spark TitleWindow&quot;</span></span>
<span style="color: #000000;">                click=<span style="color: #ff0000;">&quot;btn_clickHandler(event);&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>
&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.core.IFlexDisplayObject;</span>
<span style="color: #000000;">            import mx.events.CloseEvent;</span>
<span style="color: #000000;">            import mx.managers.PopUpManager;</span>
<span style="color: #000000;">            import spark.events.TitleWindowBoundsEvent;</span>
&nbsp;
<span style="color: #000000;">            protected function btn_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;">                // Add and center the pop up window.</span>
<span style="color: #000000;">                PopUpManager.addPopUp<span style="color: #66cc66;">&#40;</span>titleWin, this, true<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                PopUpManager.centerPopUp<span style="color: #66cc66;">&#40;</span>titleWin<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 titleWin_closeHandler<span style="color: #66cc66;">&#40;</span>evt:CloseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                // Remove the pop up window.</span>
<span style="color: #000000;">                PopUpManager.removePopUp<span style="color: #66cc66;">&#40;</span>evt.currentTarget as IFlexDisplayObject<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:TitleWindow</span> id=<span style="color: #ff0000;">&quot;titleWin&quot;</span></span>
<span style="color: #000000;">                title=<span style="color: #ff0000;">&quot;Spark TitleWindow container&quot;</span></span>
<span style="color: #000000;">                width=<span style="color: #ff0000;">&quot;240&quot;</span></span>
<span style="color: #000000;">                close=<span style="color: #ff0000;">&quot;titleWin_closeHandler(event);&quot;</span></span>
<span style="color: #000000;">                creationComplete=<span style="color: #ff0000;">&quot;titleWin.moveArea.visible = ch.selected;&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> paddingLeft=<span style="color: #ff0000;">&quot;10&quot;</span> paddingRight=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #000000;">                        paddingTop=<span style="color: #ff0000;">&quot;10&quot;</span> paddingBottom=<span style="color: #ff0000;">&quot;10&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:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CheckBox</span> id=<span style="color: #ff0000;">&quot;ch&quot;</span></span>
<span style="color: #000000;">                        label=<span style="color: #ff0000;">&quot;Should I be draggable?&quot;</span></span>
<span style="color: #000000;">                        selected=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;titleWin.moveArea.visible = ch.selected;&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;s:Label</span> text=<span style="color: #ff0000;">&quot;The quick brown fox jumps over the lazy dog.&quot;</span></span>
<span style="color: #000000;">                    width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:TitleWindow</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: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: 'Creating a non-draggable Spark TitleWindow container in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/01/19/creating-a-non-draggable-spark-titlewindow-container-in-flex-4/',contentID: 'post-2296',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'moveArea,preventDefault(),stopImmediatePropagation(),windowMoving',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/01/19/creating-a-non-draggable-spark-titlewindow-container-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a LinkElement in a Spark RichEditableText control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 14:09:17 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[RichEditableText]]></category>
		<category><![CDATA[flowElement]]></category>
		<category><![CDATA[getFirstLeaf()]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[href]]></category>
		<category><![CDATA[LinkElement]]></category>
		<category><![CDATA[preventDefault()]]></category>
		<category><![CDATA[stopImmediatePropagation()]]></category>
		<category><![CDATA[target]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=1750</guid>
		<description><![CDATA[<p>The following example shows how you can create a clickable link which pops up an Alert control in a Spark RichEditableText object&#8217;s text flow by using the &#60;a /&#62; tag and defining a click handler to the LinkElement.</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/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_RichEditableText_textFlow_LinkElement_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; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create a clickable link which pops up an Alert control in a Spark RichEditableText object&#8217;s text flow by using the &lt;a /&gt; tag and defining a <code>click</code> handler to the LinkElement.</p>
<p>Full code after the jump.</p>
<p><span id="more-1750"></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/08/27/creating-a-linkelement-in-a-spark-richeditabletext-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_RichEditableText_textFlow_LinkElement_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 flashx.textLayout.elements.LinkElement;</span>
<span style="color: #000000;">            import flashx.textLayout.events.FlowElementMouseEvent;</span>
<span style="color: #000000;">            import mx.controls.Alert;</span>
&nbsp;
<span style="color: #000000;">            protected function linkelement1_clickHandler<span style="color: #66cc66;">&#40;</span>evt:FlowElementMouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var linkEl:LinkElement = evt.flowElement as LinkElement;</span>
<span style="color: #000000;">                Alert.show<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;The '&quot;</span> + linkEl.getFirstLeaf<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.text + <span style="color: #ff0000;">&quot;' link would have gone to &quot;</span> + linkEl.href + <span style="color: #ff0000;">&quot; in a &quot;</span> + linkEl.target + <span style="color: #ff0000;">&quot; window, but it was cancelled.&quot;</span>, <span style="color: #ff0000;">&quot;Fun with hyperlinks&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                evt.stopImmediatePropagation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                evt.preventDefault<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:RichEditableText</span> id=<span style="color: #ff0000;">&quot;richEdTxt&quot;</span></span>
<span style="color: #000000;">            editable=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #000000;">            focusEnabled=<span style="color: #ff0000;">&quot;false&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: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:p</span><span style="color: #7400FF;">&gt;</span></span>I am a paragraph that happens to have a <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:a</span> href=<span style="color: #ff0000;">&quot;http://adobe.com/&quot;</span> target=<span style="color: #ff0000;">&quot;_blank&quot;</span> click=<span style="color: #ff0000;">&quot;linkelement1_clickHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>hyperlink<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:a</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>
            <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:RichEditableText</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_RichEditableText_textFlow_LinkElement_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_RichEditableText_textFlow_LinkElement_test/bin/main.html" width="100%" height="200"></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 LinkElement in a Spark RichEditableText control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/',contentID: 'post-1750',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'flowElement,getFirstLeaf(),Gumbo,href,LinkElement,preventDefault(),stopImmediatePropagation(),target,Text',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/08/27/creating-a-linkelement-in-a-spark-richeditabletext-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Preventing specific item selection on a Spark DropDownList control in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-control-in-flex-gumbo/</link>
		<comments>http://blog.flexexamples.com/2009/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-control-in-flex-gumbo/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 06:59:37 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[DropDownList (Spark)]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[changing]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[preventDefault()]]></category>
		<category><![CDATA[selectionChanged]]></category>
		<category><![CDATA[selectionChanging]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-control-in-flex-gumbo/</guid>
		<description><![CDATA[<p>The following example shows how you can prevent selection of specific items in a Spark DropDownList control in Flex 4 by listening for the changing event and calling the preventDefault() method.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2009/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-control-in-flex-gumbo/ --&#62; &#60;s:Application name=&#34;Spark_DropDownList_selectionChanging_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns=&#34;library://ns.adobe.com/flex/mx&#34;&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; import mx.controls.Alert; import spark.events.IndexChangeEvent; &#160; protected function dropDownList_changingHandler&#40;evt:IndexChangeEvent&#41;:void &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can prevent selection of specific items in a Spark DropDownList control in Flex 4 by listening for the <code>changing</code> event and calling the <code>preventDefault()</code> method.</p>
<p><span id="more-1045"></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/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-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_DropDownList_selectionChanging_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=<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 spark.events.IndexChangeEvent;</span>
&nbsp;
<span style="color: #000000;">            protected function dropDownList_changingHandler<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 ddl:DropDownList = evt.currentTarget as DropDownList;</span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>ddl.selectedItem != null<span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span>ddl.selectedItem.hasOwnProperty<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;selectable&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span>!ddl.selectedItem.selectable<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    evt.stopImmediatePropagation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                    evt.preventDefault<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 dropDownList_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;">                Alert.show<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Spark DropDownList selection was changed.&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;s:DropDownList</span> id=<span style="color: #ff0000;">&quot;dropDownList&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;label&quot;</span></span>
<span style="color: #000000;">            prompt=<span style="color: #ff0000;">&quot;Please select a string...&quot;</span></span>
<span style="color: #000000;">            changing=<span style="color: #ff0000;">&quot;dropDownList_changingHandler(event);&quot;</span></span>
<span style="color: #000000;">            change=<span style="color: #ff0000;">&quot;dropDownList_changeHandler(event);&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;200&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">            top=<span style="color: #ff0000;">&quot;10&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;The&quot;</span> selectable=<span style="color: #ff0000;">&quot;false&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;  Quick&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;  Brown&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;  Fox&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;  Jumps&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;  Over&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;The&quot;</span> selectable=<span style="color: #ff0000;">&quot;false&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;  Lazy&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;  Dog&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:DropDownList</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>

<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 class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Spark_DropDownList_selectionChanging_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_DropDownList_selectionChanging_test/main.html" width="100%" height="200"></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: 'Preventing specific item selection on a Spark DropDownList control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-control-in-flex-gumbo/',contentID: 'post-1045',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'change,changing,Gumbo,preventDefault(),selectionChanged,selectionChanging',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/04/11/preventing-specific-item-selection-on-a-spark-dropdownlist-control-in-flex-gumbo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing line feeds in a TextArea control in Flex</title>
		<link>http://blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 05:56:07 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[TextArea]]></category>
		<category><![CDATA[TextEvent]]></category>
		<category><![CDATA[TextInput]]></category>
		<category><![CDATA[preventDefault()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can prevent a user from pressing Enter in a Flex TextArea control by listening for the textInput event and checking the TextEvent object&#8217;s text property for a newline character (&#8220;\n&#8221;).</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34;&#62; &#160; &#60;mx:Script&#62; &#60;![CDATA[ private function textArea_textInput(evt:TextEvent):void { [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can prevent a user from pressing Enter in a Flex TextArea control by listening for the <code>textInput</code> event and checking the TextEvent object&#8217;s <code>text</code> property for a newline character (&#8220;\n&#8221;).</p>
<p><span id="more-548"></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/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> 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: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            private function textArea_textInput(evt:TextEvent):void {</span>
<span style="color: #339933;">                if (evt.text == &quot;\\n&quot;) {</span>
<span style="color: #339933;">                    evt.preventDefault();</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:TextArea</span> id=<span style="color: #ff0000;">&quot;textArea&quot;</span></span>
<span style="color: #000000;">            verticalScrollPolicy=<span style="color: #ff0000;">&quot;on&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;160&quot;</span></span>
<span style="color: #000000;">            height=<span style="color: #ff0000;">&quot;120&quot;</span></span>
<span style="color: #000000;">            textInput=<span style="color: #ff0000;">&quot;textArea_textInput(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:text</span><span style="color: #7400FF;">&gt;</span></span>The quick brown fox jumped over the lazy dog.<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:text</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:TextArea</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/TextArea_textInput_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/TextArea_textInput_test/bin/main.html" width="100%" height="200"></iframe></p>
<p class="new">Update 8/19/2008: If you want to prevent a user from pasting text with a carriage return/linefeed, you could listen for the <code>change</code> event and use the String class&#8217;s <code>replace()</code> method to replace any newline (&#8220;\n&#8221;) or linefeed (&#8220;\r&#8221;) with an empty string, 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/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> 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: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            private function textArea_textInput(evt:TextEvent):void {</span>
<span style="color: #339933;">                if (evt.text == &quot;\\n&quot;) {</span>
<span style="color: #339933;">                    evt.preventDefault();</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">            private function textArea_change(evt:Event):void {</span>
<span style="color: #339933;">                textArea.text = textArea.text.replace(/\\n|\\r/ig, &quot;&quot;);</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:TextArea</span> id=<span style="color: #ff0000;">&quot;textArea&quot;</span></span>
<span style="color: #000000;">            text=<span style="color: #ff0000;">&quot;The quick brown fox jumped over the lazy dog.&quot;</span></span>
<span style="color: #000000;">            verticalScrollPolicy=<span style="color: #ff0000;">&quot;on&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">            height=<span style="color: #ff0000;">&quot;100%&quot;</span></span>
<span style="color: #000000;">            textInput=<span style="color: #ff0000;">&quot;textArea_textInput(event);&quot;</span></span>
<span style="color: #000000;">            change=<span style="color: #ff0000;">&quot;textArea_change(event);&quot;</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>

<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Preventing line feeds in a TextArea control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/',contentID: 'post-548',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'preventDefault()',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/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

