<?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; RadioButton</title>
	<atom:link href="http://blog.flexexamples.com/category/halo/radiobutton/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>Detecting when the number of radio buttons changes in a radio button group in Flex</title>
		<link>http://blog.flexexamples.com/2008/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 03:56:55 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[numRadioButtonsChanged]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can detect when the number of RadioButton objects changes in a RadioButtonGroup in Flex by listening for the numRadioButtonsChanged event.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" initialize="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; private function init():void [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can detect when the number of RadioButton objects changes in a RadioButtonGroup in Flex by listening for the <code>numRadioButtonsChanged</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-679"></span></p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

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

            private function init():void {
                radioGroup.addEventListener("numRadioButtonsChanged", radioGroup_numRadioButtonsChanged);
            }

            private function radioGroup_numRadioButtonsChanged(evt:Event):void {
                var rb:RadioButton = radioGroup.getRadioButtonAt(radioGroup.numRadioButtons-1);
                var alert:Alert = Alert.show(evt.toString(), "label:" + rb.label);
                alert.status = "numRadioButtons:" + radioGroup.numRadioButtons;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:RadioButtonGroup id="radioGroup" /&gt;

    &lt;mx:HBox&gt;
        &lt;mx:RadioButton id="radioButton1" label="Red" group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton2" label="Orange" group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton3" label="Yellow" group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton4" label="Green" group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton5" label="Blue" group="{radioGroup}" /&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when the number of radio buttons changes in a radio button group in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/',contentID: 'post-679',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'numRadioButtonsChanged',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/11/10/detecting-when-the-number-of-radio-buttons-changes-in-a-radio-button-group-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting the button label placement on a RadioButton control in Flex</title>
		<link>http://blog.flexexamples.com/2008/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 06:16:07 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[labelPlacement]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the button label placement on a Flex RadioButton control by setting the labelPlacement property in MXML or ActionScript.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_labelPlacement_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/ --&#62; &#60;mx:Application name="RadioButton_labelPlacement_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.ButtonLabelPlacement; private const arr:Array [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the button label placement on a Flex RadioButton control by setting the <code>labelPlacement</code> property in MXML or ActionScript.</p>
<p>Full code after the jump.</p>
<p><span id="more-751"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_labelPlacement_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/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/ --&gt;
&lt;mx:Application name="RadioButton_labelPlacement_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

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

            private const arr:Array = [ButtonLabelPlacement.LEFT,
                                        ButtonLabelPlacement.RIGHT,
                                        ButtonLabelPlacement.TOP,
                                        ButtonLabelPlacement.BOTTOM];
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="labelPlacement:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        dataProvider="{arr}"
                        selectedIndex="1" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButton id="radioButton"
            label="RadioButton"
            labelPlacement="{comboBox.selectedItem}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_labelPlacement_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/RadioButton_labelPlacement_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>You can also set the <code>labelPlacement</code> property using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_labelPlacement_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/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/ --&gt;
&lt;mx:Application name="RadioButton_labelPlacement_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

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

            private const arr:Array = [ButtonLabelPlacement.LEFT,
                                        ButtonLabelPlacement.RIGHT,
                                        ButtonLabelPlacement.TOP,
                                        ButtonLabelPlacement.BOTTOM];

            private function comboBox_change(evt:ListEvent):void {
                var value:String = comboBox.selectedItem.toString();
                radioButton.labelPlacement = value;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="labelPlacement:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        dataProvider="{arr}"
                        selectedIndex="1"
                        change="comboBox_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButton id="radioButton"
            label="RadioButton" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the button label placement on a RadioButton control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/',contentID: 'post-751',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'labelPlacement',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/08/18/setting-the-button-label-placement-on-a-radiobutton-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Detecting when a RadioButtonGroup has been enabled or disabled in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 15:03:42 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[enabled]]></category>
		<category><![CDATA[enabledChanged]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/">&#8220;Enabling and disabling RadioButton controls in a RadioButtonGroup in Flex&#8221;</a>, we saw how you can enable or disable all of the RadioButton controls in a Flex RadioButtonGroup by setting the enabled property.</p> <p>The following example shows how you can detect when the enabled property changes by using the enabledChanged event.</p> [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/">&#8220;Enabling and disabling RadioButton controls in a RadioButtonGroup in Flex&#8221;</a>, we saw how you can enable or disable all of the RadioButton controls in a Flex RadioButtonGroup by setting the <code>enabled</code> property.</p>
<p>The following example shows how you can detect when the enabled property changes by using the <code>enabledChanged</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-680"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_enabledChanged_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/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

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

            private function init():void {
                radioGroup.addEventListener("enabledChanged",
                            radioGroup_enabledChanged);
            }

            private function radioGroup_enabledChanged(evt:Event):void {
                Alert.show("RadioButtonGroup enabled was changed",
                            "enabled: " + radioGroup.enabled);
            }

            private function checkBox_change(evt:Event):void {
                radioGroup.enabled = !radioGroup.enabled;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="enabled:"&gt;
                &lt;mx:CheckBox id="checkBox"
                        selected="true"
                        change="checkBox_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id="radioGroup" /&gt;

    &lt;mx:HBox horizontalGap="54"&gt;
        &lt;mx:RadioButton id="radioButton1"
                label="Red"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton2"
                label="Orange"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton3"
                label="Yellow"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton4"
                label="Green"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton5"
                label="Blue"
                group="{radioGroup}" /&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_enabledChanged_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_enabledChanged_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/RadioButtonGroup_enabledChanged_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/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.containers.HBox;
            import mx.controls.Alert;
            import mx.controls.CheckBox;
            import mx.controls.RadioButton;
            import mx.controls.RadioButtonGroup;

            private var checkBox:CheckBox;
            private var radioGroup:RadioButtonGroup;
            private var radioButton1:RadioButton;
            private var radioButton2:RadioButton;
            private var radioButton3:RadioButton;
            private var radioButton4:RadioButton;
            private var radioButton5:RadioButton;

            private function init():void {
                checkBox = new CheckBox();
                checkBox.selected = true;
                checkBox.addEventListener(Event.CHANGE, checkBox_change);

                var formItem:FormItem = new FormItem();
                formItem.label = "enabled:";
                formItem.addChild(checkBox);

                var form:Form = new Form();
                form.styleName = "plain";
                form.addChild(formItem);

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

                radioGroup = new RadioButtonGroup();
                radioGroup.addEventListener("enabledChanged", radioGroup_enabledChanged);

                radioButton1 = new RadioButton();
                radioButton1.label = "Red";
                radioButton1.group = radioGroup;

                radioButton2 = new RadioButton();
                radioButton2.label = "Orange";
                radioButton2.group = radioGroup;

                radioButton3 = new RadioButton();
                radioButton3.label = "Yellow";
                radioButton3.group = radioGroup;

                radioButton4 = new RadioButton();
                radioButton4.label = "Green";
                radioButton4.group = radioGroup;

                radioButton5 = new RadioButton();
                radioButton5.label = "Blue";
                radioButton5.group = radioGroup;

                var hBox:HBox = new HBox();
                hBox.setStyle("horizontalGap", 54);
                hBox.addChild(radioButton1);
                hBox.addChild(radioButton2);
                hBox.addChild(radioButton3);
                hBox.addChild(radioButton4);
                hBox.addChild(radioButton5);
                addChild(hBox);
            }

            private function radioGroup_enabledChanged(evt:Event):void {
                Alert.show("RadioButtonGroup enabled was changed",
                            "enabled: " + radioGroup.enabled);
            }

            private function checkBox_change(evt:Event):void {
                radioGroup.enabled = !radioGroup.enabled;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when a RadioButtonGroup has been enabled or disabled in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/',contentID: 'post-680',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'enabled,enabledChanged',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/25/detecting-when-a-radiobuttongroup-has-been-enabled-or-disabled-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disabling keyboard navigation on the RadioButton control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 03:07:19 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[KeyboardEvent]]></category>
		<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[keyDownHandler()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can disable keyboard navigation within a Flex RadioButton/RadioButtonGroup by extending the RadioButton class and overriding the protected keyDownHandler() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_keyDownHandler_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comps="comps.*" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:RadioButtonGroup id="radioGroup1" /&#62; &#60;mx:RadioButtonGroup id="radioGroup2" /&#62; &#60;mx:Form&#62; &#60;mx:FormItem [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can disable keyboard navigation within a Flex RadioButton/RadioButtonGroup by extending the RadioButton class and overriding the protected <code>keyDownHandler()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-681"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_keyDownHandler_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/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:comps="comps.*"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:RadioButtonGroup id="radioGroup1" /&gt;
    &lt;mx:RadioButtonGroup id="radioGroup2" /&gt;

    &lt;mx:Form&gt;
        &lt;mx:FormItem label="keyboard enabled:"
                direction="horizontal"&gt;
            &lt;mx:RadioButton id="radioButton1"
                    label="Red"
                    group="{radioGroup1}" /&gt;
            &lt;mx:RadioButton id="radioButton2"
                    label="Orange"
                    group="{radioGroup1}" /&gt;
            &lt;mx:RadioButton id="radioButton3"
                    label="Yellow"
                    group="{radioGroup1}" /&gt;
            &lt;mx:RadioButton id="radioButton4"
                    label="Green"
                    group="{radioGroup1}" /&gt;
            &lt;mx:RadioButton id="radioButton5"
                    label="Blue"
                    group="{radioGroup1}" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem label="keyboard disabled:"
                direction="horizontal"&gt;
            &lt;comps:MyRadioButton id="radioButton6"
                    label="Red"
                    group="{radioGroup2}" /&gt;
            &lt;comps:MyRadioButton id="radioButton7"
                    label="Orange"
                    group="{radioGroup2}" /&gt;
            &lt;comps:MyRadioButton id="radioButton8"
                    label="Yellow"
                    group="{radioGroup2}" /&gt;
            &lt;comps:MyRadioButton id="radioButton9"
                    label="Green"
                    group="{radioGroup2}" /&gt;
            &lt;comps:MyRadioButton id="radioButton0"
                    label="Blue"
                    group="{radioGroup2}" /&gt;
        &lt;/mx:FormItem&gt;
    &lt;/mx:Form&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_keyDownHandler_test/bin/srcview/source/comps/MyRadioButton.as.html">comps/MyRadioButton.as</a></p>
<pre class="code">
/**
 * http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/
 */
package comps {
    import flash.events.KeyboardEvent;
    import mx.controls.RadioButton;

    public class MyRadioButton extends RadioButton {
        public function MyRadioButton() {
            super();
        }

        override protected function keyDownHandler(event:KeyboardEvent):void {
            // ignore
        }
    }
}
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_keyDownHandler_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/RadioButton_keyDownHandler_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>You can also override the <code>keyDownHandler()</code> method using a custom MXML component, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_keyDownHandler_test/bin/srcview/source/comps/MyRadioButton2.mxml.html">comps/MyRadioButton2.mxml</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/ --&gt;
&lt;mx:RadioButton xmlns:mx="http://www.adobe.com/2006/mxml"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            override protected function keyDownHandler(event:KeyboardEvent):void {
                // ignore
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:RadioButton&gt;
</pre>
<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/RadioButton_keyDownHandler_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/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import comps.*;

            import mx.containers.FormItemDirection;
            import mx.containers.FormItem;
            import mx.containers.Form;
            import mx.controls.RadioButton;
            import mx.controls.RadioButtonGroup;

            private var radioGroup1:RadioButtonGroup;
            private var radioGroup2:RadioButtonGroup;

            private var radioButton1:RadioButton;
            private var radioButton2:RadioButton;
            private var radioButton3:RadioButton;
            private var radioButton4:RadioButton;
            private var radioButton5:RadioButton;

            private var radioButton6:MyRadioButton;
            private var radioButton7:MyRadioButton;
            private var radioButton8:MyRadioButton;
            private var radioButton9:MyRadioButton;
            private var radioButton0:MyRadioButton;

            private function init():void {
                radioGroup1 = new RadioButtonGroup();
                radioGroup2 = new RadioButtonGroup();

                // 1
                radioButton1 = new RadioButton();
                radioButton1.label = "Red";
                radioButton1.group = radioGroup1;
                // 2
                radioButton2 = new RadioButton();
                radioButton2.label = "Orange";
                radioButton2.group = radioGroup1;
                // 3
                radioButton3 = new RadioButton();
                radioButton3.label = "Yellow";
                radioButton3.group = radioGroup1;
                // 4
                radioButton4 = new RadioButton();
                radioButton4.label = "Green";
                radioButton4.group = radioGroup1;
                // 5
                radioButton5 = new RadioButton();
                radioButton5.label = "Blue";
                radioButton5.group = radioGroup1;

                // 6
                radioButton6 = new MyRadioButton();
                radioButton6.label = "Red";
                radioButton6.group = radioGroup2;
                // 7
                radioButton7 = new MyRadioButton();
                radioButton7.label = "Orange";
                radioButton7.group = radioGroup2;
                // 8
                radioButton8 = new MyRadioButton();
                radioButton8.label = "Yellow";
                radioButton8.group = radioGroup2;
                // 9
                radioButton9 = new MyRadioButton();
                radioButton9.label = "Green";
                radioButton9.group = radioGroup2;
                // 0
                radioButton0 = new MyRadioButton();
                radioButton0.label = "Blue";
                radioButton0.group = radioGroup2;

                var formItem1:FormItem = new FormItem();
                formItem1.label = "keyboard enabled:";
                formItem1.direction = FormItemDirection.HORIZONTAL;
                formItem1.addChild(radioButton1);
                formItem1.addChild(radioButton2);
                formItem1.addChild(radioButton3);
                formItem1.addChild(radioButton4);
                formItem1.addChild(radioButton5);

                var formItem2:FormItem = new FormItem();
                formItem2.label = "keyboard disabled:";
                formItem2.direction = FormItemDirection.HORIZONTAL;
                formItem2.addChild(radioButton6);
                formItem2.addChild(radioButton7);
                formItem2.addChild(radioButton8);
                formItem2.addChild(radioButton9);
                formItem2.addChild(radioButton0);

                var form:Form = new Form();
                form.addChild(formItem1);
                form.addChild(formItem2);
                addChild(form);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Disabling keyboard navigation on the RadioButton control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/',contentID: 'post-681',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'keyDownHandler()',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/23/disabling-keyboard-navigation-on-the-radiobutton-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Detecting when a RadioButton has been clicked in a RadioButtonGroup in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 01:52:05 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[itemClick]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can detect when a RadioButton has been clicked in a FlexRadioButtonGroup by listening for the itemClick event.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_itemClick_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.events.ItemClickEvent; private function radioGroup_itemClick(evt:ItemClickEvent):void { var now:String = [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can detect when a RadioButton has been clicked in a FlexRadioButtonGroup by listening for the <code>itemClick</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-678"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_itemClick_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/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

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

            private function radioGroup_itemClick(evt:ItemClickEvent):void {
                var now:String = new Date().toTimeString();
                lbl.text = evt.label + " (" + now + ")";
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Label id="lbl" fontWeight="bold" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id="radioGroup"
            itemClick="radioGroup_itemClick(event);" /&gt;

    &lt;mx:VBox&gt;
        &lt;mx:RadioButton id="radioButton1"
                label="Red"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton2"
                label="Orange"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton3"
                label="Yellow"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton4"
                label="Green"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton5"
                label="Blue"
                group="{radioGroup}" /&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_itemClick_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_itemClick_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/RadioButtonGroup_itemClick_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/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.VBox;
            import mx.containers.ApplicationControlBar;
            import mx.controls.Label;
            import mx.controls.RadioButton;
            import mx.controls.RadioButtonGroup;
            import mx.events.ItemClickEvent;

            private var lbl:Label;
            private var radioGroup:RadioButtonGroup;
            private var radioButton1:RadioButton;
            private var radioButton2:RadioButton;
            private var radioButton3:RadioButton;
            private var radioButton4:RadioButton;
            private var radioButton5:RadioButton;

            private function init():void {
                lbl = new Label();
                lbl.setStyle("fontWeight", "bold");

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

                radioGroup = new RadioButtonGroup();
                radioGroup.addEventListener(ItemClickEvent.ITEM_CLICK,
                            radioGroup_itemClick);

                radioButton1 = new RadioButton();
                radioButton1.label = "Red";
                radioButton1.group = radioGroup;

                radioButton2 = new RadioButton();
                radioButton2.label = "Orange";
                radioButton2.group = radioGroup;

                radioButton3 = new RadioButton();
                radioButton3.label = "Yellow";
                radioButton3.group = radioGroup;

                radioButton4 = new RadioButton();
                radioButton4.label = "Green";
                radioButton4.group = radioGroup;

                radioButton5 = new RadioButton();
                radioButton5.label = "Blue";
                radioButton5.group = radioGroup;

                var vBox:VBox = new VBox();
                vBox.addChild(radioButton1);
                vBox.addChild(radioButton2);
                vBox.addChild(radioButton3);
                vBox.addChild(radioButton4);
                vBox.addChild(radioButton5);
                addChild(vBox);
            }

            private function radioGroup_itemClick(evt:ItemClickEvent):void {
                var now:String = new Date().toTimeString();
                lbl.text = evt.label + " (" + now + ")";
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<p>For an example of detecting when a RadioButton selection has changed using the RadioButton control&#8217;s <code>change</code> event or the RadioButtonGroup&#8217;s <code>change</code> event, see <a href="http://blog.flexexamples.com/2007/10/19/determining-when-the-selected-radio-button-has-changed/">&#8220;Determining when the selected radio button has changed&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when a RadioButton has been clicked in a RadioButtonGroup in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/',contentID: 'post-678',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'itemClick',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/21/detecting-when-a-radiobutton-has-been-clicked-in-a-radiobuttongroup-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Looping over RadioButton controls in a RadioButtonGroup in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 06:58:52 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[getRadioButtonAt()]]></category>
		<category><![CDATA[numRadioButtons]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can loop over the RadioButton controls in a Flex RadioButtonGroup by using the numRadioButtons property and getRadioButtonAt() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_numRadioButtons_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; private function showAlert():void { var arr:Array [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can loop over the RadioButton controls in a Flex RadioButtonGroup by using the <code>numRadioButtons</code> property and <code>getRadioButtonAt()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-677"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_numRadioButtons_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/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

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

            private function showAlert():void {
                var arr:Array = [];
                var rb:RadioButton;
                var idx:int;
                var len:int = radioGroup.numRadioButtons;

                for (idx=0; idx&lt;len; idx++) {
                    rb = radioGroup.getRadioButtonAt(idx);
                    arr.push("index:" + idx + ", label:" + rb.label);
                }
                Alert.show(arr.join("\\n"), "getRadioButtonAt():");
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Click me" click="showAlert();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id="radioGroup" /&gt;

    &lt;mx:VBox&gt;
        &lt;mx:RadioButton id="radioButton1" label="One" /&gt;
        &lt;mx:RadioButton id="radioButton2" label="Two" /&gt;
        &lt;mx:RadioButton id="radioButton3" label="Three" /&gt;
        &lt;mx:RadioButton id="radioButton4" label="Four" /&gt;
        &lt;mx:RadioButton id="radioButton5" label="Five" /&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_numRadioButtons_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_numRadioButtons_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Looping over RadioButton controls in a RadioButtonGroup in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/',contentID: 'post-677',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getRadioButtonAt(),numRadioButtons',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/20/looping-over-radiobutton-controls-in-a-radiobuttongroup-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling and disabling RadioButton controls in a RadioButtonGroup in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 04:20:43 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[enabled]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the visibility of all of the RadioButton controls in a Flex RadioButtonGroup by setting the enabled property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_enabled_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:ApplicationControlBar dock="true"&#62; &#60;mx:Form styleName="plain"&#62; &#60;mx:FormItem label="enabled:"&#62; &#60;mx:CheckBox id="checkBox" selected="true" [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the visibility of all of the RadioButton controls in a Flex RadioButtonGroup by setting the <code>enabled</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-676"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_enabled_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/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="enabled:"&gt;
                &lt;mx:CheckBox id="checkBox"
                        selected="true" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id="radioGroup"
            enabled="{checkBox.selected}" /&gt;

    &lt;mx:VBox horizontalAlign="left"&gt;
        &lt;mx:RadioButton id="radioButton1"
                label="Red"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton2"
                label="Orange"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton3"
                label="Yellow"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton4"
                label="Green"
                group="{radioGroup}" /&gt;
        &lt;mx:RadioButton id="radioButton5"
                label="Blue"
                group="{radioGroup}" /&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_enabled_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_enabled_test/bin/main.html" width="100%" height="250"></iframe></p>
<p>You can also set the RadioButtonGroup&#8217;s <code>enabled</code> property using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_enabled_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    <strong style="color:red;">&lt;mx:Script&gt;
        &lt;![CDATA[
            private function checkBox_change(evt:Event):void {
                radioGroup.enabled = checkBox.selected;
            }
        ]]&gt;
    &lt;/mx:Script&gt;</strong>

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Form styleName=&quot;plain&quot;&gt;
            &lt;mx:FormItem label=&quot;enabled:&quot;&gt;
                &lt;mx:CheckBox id=&quot;checkBox&quot;
                        selected=&quot;true&quot;
                        <strong style="color:red;">change=&quot;checkBox_change(event);&quot;</strong> /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id=&quot;radioGroup&quot; /&gt;

    &lt;mx:VBox horizontalAlign=&quot;left&quot;&gt;
        &lt;mx:RadioButton id=&quot;radioButton1&quot;
                label=&quot;Red&quot;
                group=&quot;{radioGroup}&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton2&quot;
                label=&quot;Orange&quot;
                group=&quot;{radioGroup}&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton3&quot;
                label=&quot;Yellow&quot;
                group=&quot;{radioGroup}&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton4&quot;
                label=&quot;Green&quot;
                group=&quot;{radioGroup}&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton5&quot;
                label=&quot;Blue&quot;
                group=&quot;{radioGroup}&quot; /&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;
</pre>
<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/RadioButtonGroup_enabled_test/bin/srcview/source/main3.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.containers.VBox;
            import mx.controls.CheckBox;
            import mx.controls.RadioButton;
            import mx.controls.RadioButtonGroup;

            private var checkBox:CheckBox;
            private var radioGroup:RadioButtonGroup;
            private var radioButton1:RadioButton;
            private var radioButton2:RadioButton;
            private var radioButton3:RadioButton;
            private var radioButton4:RadioButton;
            private var radioButton5:RadioButton;

            private function init():void {
                var appControlBar:ApplicationControlBar;
                var form:Form;
                var formItem:FormItem;

                checkBox = new CheckBox();
                checkBox.selected = true;
                checkBox.addEventListener(Event.CHANGE, checkBox_change);

                formItem = new FormItem();
                formItem.label = "enabled:";
                formItem.addChild(checkBox);

                form = new Form();
                form.styleName = "plain";
                form.addChild(formItem);

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

                radioGroup = new RadioButtonGroup();

                radioButton1 = new RadioButton();
                radioButton1.label = "Red";
                radioButton1.group = radioGroup;

                radioButton2 = new RadioButton();
                radioButton2.label = "Orange";
                radioButton2.group = radioGroup;

                radioButton3 = new RadioButton();
                radioButton3.label = "Yellow";
                radioButton3.group = radioGroup;

                radioButton4 = new RadioButton();
                radioButton4.label = "Green";
                radioButton4.group = radioGroup;

                radioButton5 = new RadioButton();
                radioButton5.label = "Blue";
                radioButton5.group = radioGroup;

                var vBox:VBox = new VBox();
                vBox.addChild(radioButton1);
                vBox.addChild(radioButton2);
                vBox.addChild(radioButton3);
                vBox.addChild(radioButton4);
                vBox.addChild(radioButton5);
                addChild(vBox);
            }

            private function checkBox_change(evt:Event):void {
                radioGroup.enabled = checkBox.selected;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Enabling and disabling RadioButton controls in a RadioButtonGroup in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/',contentID: 'post-676',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'enabled',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/19/enabling-and-disabling-radiobutton-controls-in-a-radiobuttongroup-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting the label placement on a RadioButtonGroup in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 07:23:08 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[RadioButtonGroup]]></category>
		<category><![CDATA[labelPlacement]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the label placement on a series of RadioButton controls in a Flex RadioButtonGroup by setting the labelPlacement property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_labelPosition_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:ApplicationControlBar dock="true"&#62; &#60;mx:Form styleName="plain"&#62; &#60;mx:FormItem label="labelPlacement:"&#62; &#60;mx:ComboBox id="comboBox" [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the label placement on a series of RadioButton controls in a Flex RadioButtonGroup by setting the <code>labelPlacement</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-674"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_labelPosition_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/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="labelPlacement:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        dataProvider="[left, right, top, bottom]"
                        selectedIndex="1" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id="radioGroup"
            labelPlacement="{comboBox.selectedItem}" /&gt;

    &lt;mx:HBox horizontalAlign="left" verticalGap="15"&gt;
        &lt;mx:RadioButton id="radioButton1"
                label="Red"
                group="{radioGroup}"
                opaqueBackground="0xFF00FF" /&gt;
        &lt;mx:RadioButton id="radioButton2"
                label="Orange"
                group="{radioGroup}"
                opaqueBackground="0xFF00FF" /&gt;
        &lt;mx:RadioButton id="radioButton3"
                label="Yellow"
                group="{radioGroup}"
                opaqueBackground="0xFF00FF" /&gt;
        &lt;mx:RadioButton id="radioButton4"
                label="Green"
                group="{radioGroup}"
                opaqueBackground="0xFF00FF" /&gt;
        &lt;mx:RadioButton id="radioButton5"
                label="Blue"
                group="{radioGroup}"
                opaqueBackground="0xFF00FF" /&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_labelPosition_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_labelPosition_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>You can also set the <code>labelPlacement</code> property using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButtonGroup_labelPosition_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    <strong style="color:red;">&lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ListEvent;

            private function comboBox_change(evt:ListEvent):void {
                var value:String = evt.currentTarget.selectedItem;
                radioGroup.labelPlacement = value;
            }
        ]]&gt;
    &lt;/mx:Script&gt;</strong>

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Form styleName=&quot;plain&quot;&gt;
            &lt;mx:FormItem label=&quot;labelPlacement:&quot;&gt;
                &lt;mx:ComboBox id=&quot;comboBox&quot;
                        dataProvider=&quot;[left, right, top, bottom]&quot;
                        selectedIndex=&quot;1&quot;
                        <strong style="color:red;">change=&quot;comboBox_change(event);&quot;</strong> /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButtonGroup id=&quot;radioGroup&quot; /&gt;

    &lt;mx:HBox horizontalAlign=&quot;left&quot;&gt;
        &lt;mx:RadioButton id=&quot;radioButton1&quot;
                label=&quot;Red&quot;
                group=&quot;{radioGroup}&quot;
                opaqueBackground=&quot;0xFF00FF&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton2&quot;
                label=&quot;Orange&quot;
                group=&quot;{radioGroup}&quot;
                opaqueBackground=&quot;0xFF00FF&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton3&quot;
                label=&quot;Yellow&quot;
                group=&quot;{radioGroup}&quot;
                opaqueBackground=&quot;0xFF00FF&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton4&quot;
                label=&quot;Green&quot;
                group=&quot;{radioGroup}&quot;
                opaqueBackground=&quot;0xFF00FF&quot; /&gt;
        &lt;mx:RadioButton id=&quot;radioButton5&quot;
                label=&quot;Blue&quot;
                group=&quot;{radioGroup}&quot;
                opaqueBackground=&quot;0xFF00FF&quot; /&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the label placement on a RadioButtonGroup in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/',contentID: 'post-674',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'labelPlacement',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/19/setting-the-label-placement-on-a-radiobuttongroup-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting an opaque background on a RadioButton control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 05:39:17 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[opaqueBackground]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set an opaque background on a Flex RadioButton control by setting the opaqueBackground property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_opaqueBackground_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:ApplicationControlBar dock="true"&#62; &#60;mx:Form styleName="plain"&#62; &#60;mx:FormItem label="opaqueBackground:"&#62; &#60;mx:ColorPicker id="colorPicker" /&#62; &#60;/mx:FormItem&#62; &#60;/mx:Form&#62; &#60;/mx:ApplicationControlBar&#62; &#60;mx:RadioButton [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set an opaque background on a Flex RadioButton control by setting the <code>opaqueBackground</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-675"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_opaqueBackground_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/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="opaqueBackground:"&gt;
                &lt;mx:ColorPicker id="colorPicker" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButton id="radioButton"
            label="The quick brown fox jumped over the lazy dog"
            opaqueBackground="{colorPicker.selectedColor}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_opaqueBackground_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/RadioButton_opaqueBackground_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>You can also set the <code>opaqueBackground</code> property using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/RadioButton_opaqueBackground_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    <strong style="color:red;">&lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ColorPickerEvent;

            private function colorPicker_change(evt:ColorPickerEvent):void {
                radioButton.opaqueBackground = evt.color;
            }
        ]]&gt;
    &lt;/mx:Script&gt;</strong>

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Form styleName=&quot;plain&quot;&gt;
            &lt;mx:FormItem label=&quot;opaqueBackground:&quot;&gt;
                &lt;mx:ColorPicker id=&quot;colorPicker&quot;
                        <strong style="color:red;">change=&quot;colorPicker_change(event);&quot;</strong> /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:RadioButton id=&quot;radioButton&quot;
            label=&quot;The quick brown fox jumped over the lazy dog&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting an opaque background on a RadioButton control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/',contentID: 'post-675',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'opaqueBackground',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/18/setting-an-opaque-background-on-a-radiobutton-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying RadioButton controls using the Repeater in Flex (redux)</title>
		<link>http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/</link>
		<comments>http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/#comments</comments>
		<pubDate>Thu, 29 May 2008 02:33:36 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[RadioButton]]></category>
		<category><![CDATA[Repeater]]></category>
		<category><![CDATA[childDescriptors]]></category>
		<category><![CDATA[getRepeaterItem()]]></category>
		<category><![CDATA[initializeRepeater()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex/">&#8220;Displaying RadioButton controls using the Repeater in Flex&#8221;</a>, we saw how you could use a Repeater in MXML to display a series of Flex RadioButton controls based on a data provider.</p> <p>The following example shows how you can create a Repeater using ActionScript to accomplish the same thing.</p> <p>Full code [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex/">&#8220;Displaying RadioButton controls using the Repeater in Flex&#8221;</a>, we saw how you could use a Repeater in MXML to display a series of Flex RadioButton controls based on a data provider.</p>
<p>The following example shows how you can create a Repeater using ActionScript to accomplish the same thing.</p>
<p>Full code after the jump.</p>
<p><span id="more-649"></span></p>
<p class="alert">I&#8217;m not saying that creating a Repeater using ActionScript is the best/preferred/pretty way of doing this, but it is just one of many solutions.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Repeater_RadioButton_test_2/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:comps="comps.*"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;comps:MyComp /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Repeater_RadioButton_test_2/bin/srcview/source/comps/MyComp.as.html">comps/MyComp.as</a></p>
<pre class="code">
/**
 * http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/
 */
package comps {
    import flash.events.Event;

    import mx.containers.ApplicationControlBar;
    import mx.containers.Canvas;
    import mx.containers.Form;
    import mx.containers.FormItem;
    import mx.containers.HBox;
    import mx.controls.Alert;
    import mx.controls.Label;
    import mx.controls.RadioButton;
    import mx.controls.RadioButtonGroup;
    import mx.core.Application;
    import mx.core.Repeater;
    import mx.core.UIComponentDescriptor;
    import mx.styles.CSSStyleDeclaration;
    import mx.styles.StyleManager;

    public class MyComp extends Canvas {
        private var arr:Array;
        private var appControlBar:ApplicationControlBar;
        private var form:Form;
        private var formItem:FormItem;
        private var lbl:Label;
        private var hBox:HBox;
        private var radioGroup:RadioButtonGroup;
        private var radioRepeater:Repeater;

        public function MyComp() {
            super();
            init();
        }

        private function init():void {
            var alertCSS:CSSStyleDeclaration;
            alertCSS = StyleManager.getStyleDeclaration("Alert");
            alertCSS.setStyle("backgroundAlpha", 0.8);
            alertCSS.setStyle("backgroundColor", "black");
            alertCSS.setStyle("borderAlpha", 0.8);
            alertCSS.setStyle("borderColor", "black");

            arr = [];
            arr.push({label:"Red", data:"red"});
            arr.push({label:"Orange", data:"haloOrange"});
            arr.push({label:"Yellow", data:"yellow"});
            arr.push({label:"Green", data:"haloGreen"});
            arr.push({label:"Blue", data:"haloBlue"});

            radioGroup = new RadioButtonGroup();

            lbl = new Label();

            formItem = new FormItem();
            formItem.label = "selectedValue:";
            formItem.addChild(lbl);

            form = new Form();
            form.styleName = "plain";
            form.addChild(formItem);

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

            hBox = new HBox();
            hBox.setStyle("horizontalGap", 60);
            addChild(hBox);

            var descriptorProps:Object = {};
            descriptorProps.type = RadioButton;
            descriptorProps.document = this;
            descriptorProps.propertiesFactory = radioPropFac;
            descriptorProps.events = {change:"radioButton_change"};

            var radioDescriptor:UIComponentDescriptor = new UIComponentDescriptor(descriptorProps);

            radioRepeater = new Repeater();
            radioRepeater.dataProvider = arr;
            radioRepeater.childDescriptors = [radioDescriptor];
            radioRepeater.initializeRepeater(hBox, true);
        }

        private function radioPropFac():Object {
            var obj:Object = {};
            obj.label = radioRepeater.currentItem.label;
            obj.group = radioGroup;
            return obj;
        }

        public function radioButton_change(evt:Event):void {
            var radio:RadioButton = RadioButton(evt.currentTarget);
            var item:Object = radio.getRepeaterItem();
            var cssObj:CSSStyleDeclaration;
            cssObj = StyleManager.getStyleDeclaration("Alert");
            cssObj.setStyle("modalTransparencyColor", item.data);
            cssObj.setStyle("themeColor", item.data);
            Alert.show(item.label, "getRepeaterItem()");

            callLater(updateSelectedValue, [evt]);
        }

        private function updateSelectedValue(evt:Event):void {
            lbl.text = radioGroup.selectedValue.toString();
        }
    }
}
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Repeater_RadioButton_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Repeater_RadioButton_test_2/bin/main.html" width="100%" height="150"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Displaying RadioButton controls using the Repeater in Flex (redux) on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/',contentID: 'post-649',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'childDescriptors,getRepeaterItem(),initializeRepeater()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/05/28/displaying-radiobutton-controls-using-the-repeater-in-flex-redux/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

