<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Checking to see if a Flex CheckBox is selected before allowing a user to press a Button</title>
	<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Fri, 05 Dec 2008 11:32:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Ali</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-14335</link>
		<author>Ali</author>
		<pubDate>Fri, 25 Jul 2008 03:43:58 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-14335</guid>
		<description>sweet web site dude!</description>
		<content:encoded><![CDATA[<p>sweet web site dude!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9638</link>
		<author>Nick</author>
		<pubDate>Wed, 02 Apr 2008 21:18:20 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9638</guid>
		<description>Thank you so much, I used the XML example (I'm more familiar with XML than actionscript) and it worked perfectly. I have one last question/request however.

In the project I'm using, I use a seperate MXML file and put it into the main project, and the way FLEX refers to it is by using some  command that I haven't been able to find any information online. I was wondering if you knew how to have a checkbox inside this seperate MXML file and have it make the button appear in the main MXML file. I'm sorry if it's not too clear.

-Nick</description>
		<content:encoded><![CDATA[<p>Thank you so much, I used the XML example (I&#8217;m more familiar with XML than actionscript) and it worked perfectly. I have one last question/request however.</p>
<p>In the project I&#8217;m using, I use a seperate MXML file and put it into the main project, and the way FLEX refers to it is by using some  command that I haven&#8217;t been able to find any information online. I was wondering if you knew how to have a checkbox inside this seperate MXML file and have it make the button appear in the main MXML file. I&#8217;m sorry if it&#8217;s not too clear.</p>
<p>-Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9575</link>
		<author>peterd</author>
		<pubDate>Tue, 01 Apr 2008 23:56:09 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9575</guid>
		<description>Nick,

Do either of these work for you?

&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"&#62;

    &#60;mx:Panel title="Any" width="320"&#62;
        &#60;mx:CheckBox id="check1a" label="Check 1.A" /&#62;
        &#60;mx:CheckBox id="check2a" label="Check 2.A" /&#62;
        &#60;mx:CheckBox id="check3a" label="Check 3.A" /&#62;
        &#60;mx:ControlBar&#62;
            &#60;mx:Button label="Button A" enabled="{check1a.selected &#124;&#124; check2a.selected &#124;&#124; check3a.selected}" /&#62;
        &#60;/mx:ControlBar&#62;
    &#60;/mx:Panel&#62;

    &#60;mx:Panel title="All" width="320"&#62;
        &#60;mx:CheckBox id="check1b" label="Check 1.B" /&#62;
        &#60;mx:CheckBox id="check2b" label="Check 2.B" /&#62;
        &#60;mx:CheckBox id="check3b" label="Check 3.B" /&#62;
        &#60;mx:ControlBar&#62;
            &#60;mx:Button label="Button B" enabled="{check1b.selected &#38;amp;&#38;amp; check2b.selected &#38;amp;&#38;amp; check3b.selected}" /&#62;
        &#60;/mx:ControlBar&#62;
    &#60;/mx:Panel&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

Or, using ActionScript instead of MXML:
&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"&#62;

    &#60;mx:Script&#62;
        &#60;![CDATA[
            private function chkA():void {
                btnA.enabled = (check1a.selected &#124;&#124; check2a.selected &#124;&#124; check3a.selected);
            }
            private function chkB():void {
                btnB.enabled = (check1b.selected &#038;&#038; check2b.selected &#038;&#038; check3b.selected);
            }
        ]]&#62;
    &#60;/mx:Script&#62;

    &#60;mx:Panel title="Any" width="320"&#62;
        &#60;mx:CheckBox id="check1a" label="Check 1.A" change="chkA();" /&#62;
        &#60;mx:CheckBox id="check2a" label="Check 2.A" change="chkA();" /&#62;
        &#60;mx:CheckBox id="check3a" label="Check 3.A" change="chkA();" /&#62;
        &#60;mx:ControlBar&#62;
            &#60;mx:Button id="btnA" label="Button A" creationComplete="chkA();" /&#62;
        &#60;/mx:ControlBar&#62;
    &#60;/mx:Panel&#62;

    &#60;mx:Panel title="All" width="320"&#62;
        &#60;mx:CheckBox id="check1b" label="Check 1.B" change="chkB();" /&#62;
        &#60;mx:CheckBox id="check2b" label="Check 2.B" change="chkB();" /&#62;
        &#60;mx:CheckBox id="check3b" label="Check 3.B" change="chkB();" /&#62;
        &#60;mx:ControlBar&#62;
            &#60;mx:Button id="btnB" label="Button B" creationComplete="chkB();" /&#62;
        &#60;/mx:ControlBar&#62;
    &#60;/mx:Panel&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>Nick,</p>
<p>Do either of these work for you?</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"&gt;

    &lt;mx:Panel title="Any" width="320"&gt;
        &lt;mx:CheckBox id="check1a" label="Check 1.A" /&gt;
        &lt;mx:CheckBox id="check2a" label="Check 2.A" /&gt;
        &lt;mx:CheckBox id="check3a" label="Check 3.A" /&gt;
        &lt;mx:ControlBar&gt;
            &lt;mx:Button label="Button A" enabled="{check1a.selected || check2a.selected || check3a.selected}" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

    &lt;mx:Panel title="All" width="320"&gt;
        &lt;mx:CheckBox id="check1b" label="Check 1.B" /&gt;
        &lt;mx:CheckBox id="check2b" label="Check 2.B" /&gt;
        &lt;mx:CheckBox id="check3b" label="Check 3.B" /&gt;
        &lt;mx:ControlBar&gt;
            &lt;mx:Button label="Button B" enabled="{check1b.selected &amp;amp;&amp;amp; check2b.selected &amp;amp;&amp;amp; check3b.selected}" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<p>Or, using ActionScript instead of MXML:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function chkA():void {
                btnA.enabled = (check1a.selected || check2a.selected || check3a.selected);
            }
            private function chkB():void {
                btnB.enabled = (check1b.selected &#038;&#038; check2b.selected &#038;&#038; check3b.selected);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Panel title="Any" width="320"&gt;
        &lt;mx:CheckBox id="check1a" label="Check 1.A" change="chkA();" /&gt;
        &lt;mx:CheckBox id="check2a" label="Check 2.A" change="chkA();" /&gt;
        &lt;mx:CheckBox id="check3a" label="Check 3.A" change="chkA();" /&gt;
        &lt;mx:ControlBar&gt;
            &lt;mx:Button id="btnA" label="Button A" creationComplete="chkA();" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

    &lt;mx:Panel title="All" width="320"&gt;
        &lt;mx:CheckBox id="check1b" label="Check 1.B" change="chkB();" /&gt;
        &lt;mx:CheckBox id="check2b" label="Check 2.B" change="chkB();" /&gt;
        &lt;mx:CheckBox id="check3b" label="Check 3.B" change="chkB();" /&gt;
        &lt;mx:ControlBar&gt;
            &lt;mx:Button id="btnB" label="Button B" creationComplete="chkB();" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9572</link>
		<author>Nick</author>
		<pubDate>Tue, 01 Apr 2008 23:10:12 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9572</guid>
		<description>Nevermind, I've figured the problem out. However, would it be possible to have multiple checkboxes, and if any of them are selected, the button would appear?</description>
		<content:encoded><![CDATA[<p>Nevermind, I&#8217;ve figured the problem out. However, would it be possible to have multiple checkboxes, and if any of them are selected, the button would appear?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9568</link>
		<author>Nick</author>
		<pubDate>Tue, 01 Apr 2008 22:53:07 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9568</guid>
		<description>Sorry, it didn't show my script i used while posting.</description>
		<content:encoded><![CDATA[<p>Sorry, it didn&#8217;t show my script i used while posting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9567</link>
		<author>Nick</author>
		<pubDate>Tue, 01 Apr 2008 22:52:33 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-9567</guid>
		<description>I'm having a little problem with this script.

I'm using the same button in different states, and I'm just using the  function to make the button go to the next state, depending on which state its already in. However, lets say in state 1 i want the button enabled, but in state 2 I want it to be disabled, and only enabled if the checkbox is selected, i used the 

However, when I do so, the button doesn't enable itself as soon as the checkbox is selected, but if i select the checkbox, go back to state 1, and then return to state 2, then the button is enabled.

Any insight on how to fix this?

-Nick</description>
		<content:encoded><![CDATA[<p>I&#8217;m having a little problem with this script.</p>
<p>I&#8217;m using the same button in different states, and I&#8217;m just using the  function to make the button go to the next state, depending on which state its already in. However, lets say in state 1 i want the button enabled, but in state 2 I want it to be disabled, and only enabled if the checkbox is selected, i used the </p>
<p>However, when I do so, the button doesn&#8217;t enable itself as soon as the checkbox is selected, but if i select the checkbox, go back to state 1, and then return to state 2, then the button is enabled.</p>
<p>Any insight on how to fix this?</p>
<p>-Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John C. Bland II</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-2427</link>
		<author>John C. Bland II</author>
		<pubDate>Tue, 18 Sep 2007 05:18:23 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-2427</guid>
		<description>Exactly.</description>
		<content:encoded><![CDATA[<p>Exactly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-2068</link>
		<author>peterd</author>
		<pubDate>Fri, 14 Sep 2007 05:01:03 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-2068</guid>
		<description>You could always combine #2 and #3. Even if the Button control has its &lt;code&gt;enabled&lt;/code&gt; property set to &lt;code&gt;false&lt;/code&gt;, the error string will display when you roll over the button. A "win-win". I just liked #3 because it seemed the least intrusive.

BFF,
Peter</description>
		<content:encoded><![CDATA[<p>You could always combine #2 and #3. Even if the Button control has its <code>enabled</code> property set to <code>false</code>, the error string will display when you roll over the button. A &#8220;win-win&#8221;. I just liked #3 because it seemed the least intrusive.</p>
<p>BFF,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John C. Bland II</title>
		<link>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-2067</link>
		<author>John C. Bland II</author>
		<pubDate>Fri, 14 Sep 2007 04:54:51 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/13/checking-to-see-if-a-flex-checkbox-is-selected-before-allowing-a-user-to-press-a-button/#comment-2067</guid>
		<description>I personally enjoy #2 and is my #1 decision for situations like this although I do like the approach of #3.</description>
		<content:encoded><![CDATA[<p>I personally enjoy #2 and is my #1 decision for situations like this although I do like the approach of #3.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
