<?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; prompt</title>
	<atom:link href="http://blog.flexexamples.com/tag/prompt/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 a prompt on a ComboBox control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/01/setting-a-prompt-on-a-combobox-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/01/setting-a-prompt-on-a-combobox-control-in-flex/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 13:43:16 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[selectedIndex]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/01/setting-a-prompt-on-a-combobox-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set a prompt on a Flex ComboBox control by setting the prompt property.</p> <p>Full code after the jump.</p> <p></p> <p class="note">You can reset a ComboBox control so that its prompt message is visible again by setting the selectedIndex property to -1.</p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_prompt_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set a prompt on a Flex ComboBox control by setting the <code>prompt</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-654"></span></p>
<p class="note">You can reset a ComboBox control so that its prompt message is visible again by setting the <code>selectedIndex</code> property to -1.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_prompt_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/06/01/setting-a-prompt-on-a-combobox-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object abbrev="AL" name="Alabama" /&gt;
        &lt;mx:Object abbrev="AK" name="Alaska" /&gt;
        &lt;mx:Object abbrev="AZ" name="Arizona" /&gt;
        &lt;mx:Object abbrev="AR" name="Arkansas" /&gt;
        &lt;mx:Object abbrev="CA" name="California" /&gt;
        &lt;mx:Object abbrev="CO" name="Colorado" /&gt;
        &lt;mx:Object abbrev="CT" name="Connecticut" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="button"
                label="Reset ComboBox"
                click="comboBox.selectedIndex = -1;" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:ComboBox id="comboBox"
            dataProvider="{arr}"
            labelField="name"
            prompt="Please select a state..." /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_prompt_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/ComboBox_prompt_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/ComboBox_prompt_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/06/01/setting-a-prompt-on-a-combobox-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.ComboBox;
            import mx.controls.Button;
            import mx.containers.ApplicationControlBar;

            private var arr:Array;
            private var appControlBar:ApplicationControlBar;
            private var button:Button;
            private var comboBox:ComboBox;

            private function init():void {
                arr = [];
                arr.push({abbrev:"AL", name:"Alabama"});
                arr.push({abbrev:"AK", name:"Alaska"});
                arr.push({abbrev:"AZ", name:"Arizona"});
                arr.push({abbrev:"AR", name:"Arkansas"});
                arr.push({abbrev:"CA", name:"California"});
                arr.push({abbrev:"CO", name:"Colorado"});
                arr.push({abbrev:"CT", name:"Connecticut"});

                button = new Button();
                button.label = "Reset ComboBox";
                button.addEventListener(MouseEvent.CLICK, button_click);

                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(button);
                Application.application.addChildAt(appControlBar, 0);

                comboBox = new ComboBox();
                comboBox.dataProvider = arr;
                comboBox.labelField = "name";
                comboBox.prompt = "Please select a state...";
                addChild(comboBox);
            }

            private function button_click(evt:MouseEvent):void {
                comboBox.selectedIndex = -1;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting a prompt on a ComboBox control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/01/setting-a-prompt-on-a-combobox-control-in-flex/',contentID: 'post-654',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'prompt,selectedIndex',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/06/01/setting-a-prompt-on-a-combobox-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Creating a simple label function on a Flex ComboBox control</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/</link>
		<comments>http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 04:48:27 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[XMLList]]></category>
		<category><![CDATA[labelFunction]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[substitute()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/</guid>
		<description><![CDATA[<p>The following example shows how you can format the label in a ComboBox using a custom label function.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_labelFunction_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/ --&#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.utils.StringUtil; private function comboBox_labelFunc(item:Object):String { return StringUtil.substitute("{0} ({1})", item.@name, item.@abbrev); } ]]&#62; &#60;/mx:Script&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can format the label in a ComboBox using a custom label function.</p>
<p>Full code after the jump.</p>
<p><span id="more-206"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_labelFunction_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/ --&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.utils.StringUtil;

            private function comboBox_labelFunc(item:Object):String {
                return StringUtil.substitute("{0} ({1})", item.@name, item.@abbrev);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XMLList id="statesXMLList"&gt;
        &lt;state abbrev="AL" name="Alabama" /&gt;
        &lt;state abbrev="AK" name="Alaska" /&gt;
        &lt;state abbrev="AZ" name="Arizona" /&gt;
        &lt;state abbrev="AR" name="Arkansas" /&gt;
        &lt;state abbrev="CA" name="California" /&gt;
        &lt;state abbrev="CO" name="Colorado" /&gt;
        &lt;state abbrev="CT" name="Connecticut" /&gt;
    &lt;/mx:XMLList&gt;

    &lt;mx:ComboBox id="comboBox"
            prompt="Please select a State..."
            dataProvider="{statesXMLList}"
            labelFunction="comboBox_labelFunc" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_labelFunction_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/ComboBox_labelFunction_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a simple label function on a Flex ComboBox control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/',contentID: 'post-206',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'labelFunction,prompt,substitute()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

