<?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; selection</title>
	<atom:link href="http://blog.flexexamples.com/tag/selection/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>Creating a radio button item renderer on a Spark List control in Flex 4</title>
		<link>http://blog.flexexamples.com/2010/05/20/creating-a-radio-button-item-renderer-on-a-spark-list-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2010/05/20/creating-a-radio-button-item-renderer-on-a-spark-list-control-in-flex-4/#comments</comments>
		<pubDate>Thu, 20 May 2010 15:39:48 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Flex4]]></category>
		<category><![CDATA[List (Spark)]]></category>
		<category><![CDATA[RadioButton (Spark)]]></category>
		<category><![CDATA[RadioButtonGroup (Spark)]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[itemRenderer]]></category>
		<category><![CDATA[selectedValue]]></category>
		<category><![CDATA[selection]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=3133</guid>
		<description><![CDATA[<p>The following example shows how you can use a Spark RadioButton control as an item renderer for a Spark List control in Flex 4 by setting the itemRenderer property.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/05/20/creating-a-radio-button-item-renderer-on-a-spark-list-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_List_itemRenderer_RadioButton_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:Label text=&#34;selected RadioButton: {dgr1.selection.label}&#34; /&#62; &#60;/s:controlBarContent&#62; &#160; &#60;fx:Declarations&#62; &#60;s:RadioButtonGroup id=&#34;dgr1&#34; selectedValue=&#34;Three&#34; /&#62; &#60;/fx:Declarations&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use a Spark RadioButton control as an item renderer for a Spark List control in Flex 4 by setting the <code>itemRenderer</code> property.</p>
<p><span id="more-3133"></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/05/20/creating-a-radio-button-item-renderer-on-a-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_itemRenderer_RadioButton_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:Label</span> text=<span style="color: #ff0000;">&quot;selected RadioButton: {dgr1.selection.label}&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:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RadioButtonGroup</span> id=<span style="color: #ff0000;">&quot;dgr1&quot;</span> selectedValue=<span style="color: #ff0000;">&quot;Three&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> id=<span style="color: #ff0000;">&quot;lst&quot;</span></span>
<span style="color: #000000;">            itemRenderer=<span style="color: #ff0000;">&quot;skins.RadioButtonItemRen&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;100&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>
<span style="color: #000000;">                    horizontalAlign=<span style="color: #ff0000;">&quot;contentJustify&quot;</span></span>
<span style="color: #000000;">                    requestedRowCount=<span style="color: #ff0000;">&quot;6&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><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;One&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Two&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Three&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Four&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Five&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Six&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Seven&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Eight&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Object</span> val=<span style="color: #ff0000;">&quot;Nine&quot;</span> gr=<span style="color: #ff0000;">&quot;{dgr1}&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: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>

<p>And the custom Spark List item renderer, <em>skins/RadioButtonItemRen.mxml</em>, is as follows:</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/05/20/creating-a-radio-button-item-renderer-on-a-spark-list-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ItemRenderer</span> name=<span style="color: #ff0000;">&quot;RadioButtonItemRen&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;">        autoDrawBackground=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #000000;">        dataChange=<span style="color: #ff0000;">&quot;itemrenderer1_dataChangeHandler(event);&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;">            protected function itemrenderer1_dataChangeHandler<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                rdBtn.label = data.val;</span>
<span style="color: #000000;">                rdBtn.value = data.val;</span>
<span style="color: #000000;">                rdBtn.group = data.gr;</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:RadioButton</span> id=<span style="color: #ff0000;">&quot;rdBtn&quot;</span></span>
<span style="color: #000000;">            left=<span style="color: #ff0000;">&quot;3&quot;</span> right=<span style="color: #ff0000;">&quot;3&quot;</span> top=<span style="color: #ff0000;">&quot;5&quot;</span> bottom=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:ItemRenderer</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 radio button item renderer on a Spark List control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/05/20/creating-a-radio-button-item-renderer-on-a-spark-list-control-in-flex-4/',contentID: 'post-3133',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'group,Gumbo,itemRenderer,selectedValue,selection',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/05/20/creating-a-radio-button-item-renderer-on-a-spark-list-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Clearing a selected RadioButton control in Flex</title>
		<link>http://blog.flexexamples.com/2008/01/06/clearing-a-selected-radiobutton-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/01/06/clearing-a-selected-radiobutton-control-in-flex/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 08:29:29 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[selectedValue]]></category>
		<category><![CDATA[selection]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/06/clearing-a-selected-radiobutton-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can use ActionScript to clear a currently selected radio button by setting the RadioButtonGroup class&#8217;s selection property to null.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/01/06/clearing-a-selected-radiobutton-control-in-flex/ --&#62; &#60;mx:Application name=&#34;RadioButtonGroup_selection_test&#34; 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[ import mx.controls.Alert; &#160; private function reset():void { answers.selection = null; } &#160; private function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use ActionScript to clear a currently selected radio button by setting the RadioButtonGroup class&#8217;s <code>selection</code> property to <code>null</code>.</p>
<p><span id="more-419"></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/01/06/clearing-a-selected-radiobutton-control-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;RadioButtonGroup_selection_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.controls.Alert;</span>
&nbsp;
<span style="color: #339933;">            private function reset():void {</span>
<span style="color: #339933;">                answers.selection = null;</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function check():void {</span>
<span style="color: #339933;">                if (answers.selectedValue) {</span>
<span style="color: #339933;">                    Alert.show(answers.selectedValue.toString());</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    Alert.show(&quot;unselected&quot;);</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButtonGroup</span> id=<span style="color: #ff0000;">&quot;answers&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> backgroundColor=<span style="color: #ff0000;">&quot;red&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:Text</span> id=<span style="color: #ff0000;">&quot;question&quot;</span></span>
<span style="color: #000000;">                    text=<span style="color: #ff0000;">&quot;Question...&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> id=<span style="color: #ff0000;">&quot;answer1&quot;</span></span>
<span style="color: #000000;">                    group=<span style="color: #ff0000;">&quot;{answers}&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;Answer 1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> id=<span style="color: #ff0000;">&quot;answer2&quot;</span></span>
<span style="color: #000000;">                    group=<span style="color: #ff0000;">&quot;{answers}&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;Answer 2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> id=<span style="color: #ff0000;">&quot;answer3&quot;</span></span>
<span style="color: #000000;">                    group=<span style="color: #ff0000;">&quot;{answers}&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;Answer 3&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> id=<span style="color: #ff0000;">&quot;answer4&quot;</span></span>
<span style="color: #000000;">                    group=<span style="color: #ff0000;">&quot;{answers}&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;Answer 4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadioButton</span> id=<span style="color: #ff0000;">&quot;answer5&quot;</span></span>
<span style="color: #000000;">                    group=<span style="color: #ff0000;">&quot;{answers}&quot;</span></span>
<span style="color: #000000;">                    label=<span style="color: #ff0000;">&quot;Answer 5&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> direction=<span style="color: #ff0000;">&quot;horizontal&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Check&quot;</span> click=<span style="color: #ff0000;">&quot;check();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Reset&quot;</span> click=<span style="color: #ff0000;">&quot;reset();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<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://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_selection_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/RadioButtonGroup_selection_test/bin/main.html" width="100%" height="350"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Clearing a selected RadioButton control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/06/clearing-a-selected-radiobutton-control-in-flex/',contentID: 'post-419',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'selectedValue,selection',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/01/06/clearing-a-selected-radiobutton-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Creating a simple multiple-choice quiz using the RadioButton and RadioButtonGroup controls</title>
		<link>http://blog.flexexamples.com/2007/10/17/creating-a-simple-multiple-choice-quiz-using-the-radiobutton-and-radiobuttongroup-controls/</link>
		<comments>http://blog.flexexamples.com/2007/10/17/creating-a-simple-multiple-choice-quiz-using-the-radiobutton-and-radiobuttongroup-controls/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 03:42:36 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[selectedValue]]></category>
		<category><![CDATA[selection]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/10/17/creating-a-simple-multiple-choice-quiz-using-the-radiobutton-and-radiobuttongroup-controls/</guid>
		<description><![CDATA[<p>The following example shows how you can make a very simple multiple-choice type quiz using the RadioButton and RadioButtonGroup controls. Each time you make an incorrect choice and click the check answers button, the selected (incorrect) choice is removed from the Flex application. If you select the correct answer and click the check answers button, [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can make a very simple multiple-choice type quiz using the RadioButton and RadioButtonGroup controls. Each time you make an incorrect choice and click the check answers button, the selected (incorrect) choice is removed from the Flex application. If you select the correct answer and click the check answers button, all the incorrect answers are removed.</p>
<p>Full code after the jump.</p>
<p><span id="more-240"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Quiz_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/2007/10/17/creating-a-simple-multiple-choice-quiz-using-the-radiobutton-and-radiobuttongroup-controls/ --&gt;
&lt;mx:Application name="Quiz_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        RadioButton {
            paddingLeft: 20;
            horizontalGap: 4;
        }

        .QuestionVBox {
            paddingBottom: 50;
        }

        .QuestionText {
            fontWeight: bold;
        }
    &lt;/mx:Style&gt;

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

            private function checkAnswers():void {
                var success:Boolean = true;

                success = checkGroup(q1_group) &#038;& success;
                success = checkGroup(q2_group) &#038;& success;

                Alert.show("SUCCESS = " + success);
            }

            private function checkGroup(rbg:RadioButtonGroup):Boolean {
                var rb:RadioButton;
                var valid:Boolean = true;
                var i:int;

                /* If the user got the answer wrong... */
                if (rbg.selectedValue != true) {
                    /* Set the 'valid' flag to false. */
                    valid = false;
                    /* Get the currently selected radio button, if any. */
                    rb = rbg.selection;
                    /* Actually, check if a radio button WAS selected... */
                    if (rb != null) {
                        /* If there was a selected radio button, and it
                           was the wrong answer, hide the answer. */
                        rb.includeInLayout = false;
                        rb.visible = false;
                    }
                /* Else the user selected the right answer. Hey, it was
                   bound to happen eventually! */
                } else {
                    /* Loop over all the radio buttons in this group. */
                    for (i = 0; i &lt; rbg.numRadioButtons; i++) {
                        /* Create a reference to the current radio button. */
                        rb = rbg.getRadioButtonAt(i);
                        /* If the radio button is NOT selected... */
                        if (!rb.selected) {
                            /* Hide all wrong answers, they already got
                               the question right. */
                            rb.includeInLayout = false;
                            rb.visible = false;
                        }
                    }
                }

                /* Return the value of the 'valid' flag. */
                return valid;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:RadioButtonGroup id="q1_group" enabled="false" /&gt;
    &lt;mx:RadioButtonGroup id="q2_group" enabled="false" /&gt;

    &lt;mx:Panel title="Subject: Periodic Table" width="100%" height="100%"&gt;
        &lt;mx:VBox styleName="QuestionVBox" width="100%"&gt;
            &lt;mx:Text styleName="QuestionText"
                    selectable="false"
                    width="100%"&gt;
                &lt;mx:text&gt;1) Which three groups of the Periodic Table contain the most elements classified as metalloids (semimetals)?&lt;/mx:text&gt;
            &lt;/mx:Text&gt;

            &lt;!-- Wrong --&gt;
            &lt;mx:RadioButton id="q1_a"
                    label="1, 2, and 13"
                    group="{q1_group}" /&gt;
            &lt;!-- Wrong --&gt;
            &lt;mx:RadioButton id="q1_b"
                    label="2, 13, and 14"
                    group="{q1_group}" /&gt;
            &lt;!-- RIGHT --&gt;
            &lt;mx:RadioButton id="q1_c"
                    label="14, 15, and 16"
                    group="{q1_group}"
                    value="true" /&gt;
            &lt;!-- Wrong --&gt;
            &lt;mx:RadioButton id="q1_d"
                    label="16, 17, and 18"
                    group="{q1_group}" /&gt;
        &lt;/mx:VBox&gt;

        &lt;mx:VBox styleName="QuestionVBox" width="100%"&gt;
            &lt;mx:Text styleName="QuestionText"
                    selectable="false"
                    width="100%"&gt;
                &lt;mx:text&gt;2) Which element has the highest first ionization energy?&lt;/mx:text&gt;
            &lt;/mx:Text&gt;

            &lt;!-- Wrong --&gt;
            &lt;mx:RadioButton id="q2_a"
                    label="sodium"
                    group="{q2_group}" /&gt;
            &lt;!-- Wrong --&gt;
            &lt;mx:RadioButton id="q2_b"
                    label="aluminum"
                    group="{q2_group}" /&gt;
            &lt;!-- Wrong --&gt;
            &lt;mx:RadioButton id="q2_c"
                    label="calcium"
                    group="{q2_group}" /&gt;
            &lt;!-- RIGHT --&gt;
            &lt;mx:RadioButton id="q2_d"
                    label="phosphorus"
                    group="{q2_group}"
                    value="true" /&gt;
        &lt;/mx:VBox&gt;

        &lt;mx:ControlBar horizontalAlign="right"&gt;
            &lt;mx:Button label="Check answers"
                    click="checkAnswers();" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Quiz_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/Quiz_test/bin/main.html" width="100%" height="520"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a simple multiple-choice quiz using the RadioButton and RadioButtonGroup controls on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/10/17/creating-a-simple-multiple-choice-quiz-using-the-radiobutton-and-radiobuttongroup-controls/',contentID: 'post-240',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'group,selectedValue,selection',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/10/17/creating-a-simple-multiple-choice-quiz-using-the-radiobutton-and-radiobuttongroup-controls/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

