<?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>Anna Filina &#187; binding</title>
	<atom:link href="http://annafilina.com/blog/tag/binding/feed/" rel="self" type="application/rss+xml" />
	<link>http://annafilina.com/blog</link>
	<description>I fix stuff</description>
	<lastBuildDate>Thu, 17 May 2012 19:58:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Data Binding expressions</title>
		<link>http://annafilina.com/blog/data-binding-expressions/</link>
		<comments>http://annafilina.com/blog/data-binding-expressions/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 02:37:32 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[binding]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/archives/29</guid>
		<description><![CDATA[In MXML, you may use expressions as a source of data binding.
Example:
&#60;mx:Label text="Beer" visible="{age &#62;= 18}" /&#62;
The Label will only be displayed if the person is 18 or older.
Did you try a more complex expression?
&#60;mx:Label text="Beer" visible="{age &#62;= 18 &#38;&#38; gender == 'male'}" /&#62;
Ah ha! You get a compiler error. Why? Because you&#8217;re inside MXML<div><a href="http://annafilina.com/blog/data-binding-expressions/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>In MXML, you may use expressions as a source of data binding.</p>
<p>Example:</p>
<pre class="brush:xml">&lt;mx:Label text="Beer" visible="{age &gt;= 18}" /&gt;</pre>
<p>The Label will only be displayed if the person is 18 or older.</p>
<p>Did you try a more complex expression?</p>
<pre class="brush:xml">&lt;mx:Label text="Beer" visible="{age &gt;= 18 &amp;&amp; gender == 'male'}" /&gt;</pre>
<p>Ah ha! You get a compiler error. Why? Because you&#8217;re inside MXML and the &amp; character is special.</p>
<p>Solution: replace the &amp; with &amp;amp;</p>
<pre class="brush:xml">&lt;mx:Label text="Beer" visible="{age &gt;= 18 &amp;&amp; gender == 'male'}" /&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/data-binding-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Bindable] public override</title>
		<link>http://annafilina.com/blog/bindable-public-override/</link>
		<comments>http://annafilina.com/blog/bindable-public-override/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 21:51:34 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[binding]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/archives/28</guid>
		<description><![CDATA[I stumbled upon a compiler error when overriding a setter function with the Bindable metadata tag: &#8220;overriding a function that is not marked for override&#8221;
The answer is short and simple: use &#8211;[Bindable] public override&#8211; instead of &#8211;[Bindable] override public&#8211;
It may sound silly but the override actually has to come second in order for the compiler<div><a href="http://annafilina.com/blog/bindable-public-override/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I stumbled upon a compiler error when overriding a setter function with the Bindable metadata tag: &#8220;overriding a function that is not marked for override&#8221;</p>
<p>The answer is short and simple: use &#8211;[Bindable] public override&#8211; instead of &#8211;[Bindable] override public&#8211;<br />
It may sound silly but the override actually has to come second in order for the compiler to interpret it properly in this particular situation.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/bindable-public-override/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AS3 data binding and component states</title>
		<link>http://annafilina.com/blog/as3-data-binding-and-component-states/</link>
		<comments>http://annafilina.com/blog/as3-data-binding-and-component-states/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 22:54:47 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[binding]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/archives/26</guid>
		<description><![CDATA[If you ever developed a complex data-driven application, you probably stumbled upon the data binding nightmare. Altough a great feature in Flex (a central one in my opinion), it lacks a bit of control.
I needed a form with multiple states depending on the flavor of the edited object. This way, I could have common fields<div><a href="http://annafilina.com/blog/as3-data-binding-and-component-states/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>If you ever developed a complex data-driven application, you probably stumbled upon the data binding nightmare. Altough a great feature in Flex (a central one in my opinion), it lacks a bit of control.</p>
<p>I needed a form with multiple states depending on the flavor of the edited object. This way, I could have common fields to all object types and add a couple of fields based on the object type. However, these fields&#8217; values were bound to properties of the edited object. When selecting an object from the list, the fields should update themselves. Bindings are executed to set field values. Now, since I use form states, all fields are technically on the stage and all bindings will execute, regardless of the type of the selected object.</p>
<p>Basic example</p>
<p>I have a form to edit animal properties (number of legs, head size, etc.)</p>
<p>I have some extra fields depending on the animal type (mammals have fur length and density, birds have wing span, etc.)</p>
<p>Every animal type has an associated state:</p>
<pre class="brush:xml">&lt;mx:Form&gt;
    &lt;mx:FormItem label="Legs"&gt;
        &lt;mx:TextInput text="{animal.legs}"/&gt;
    &lt;/mx:FormItem&gt;
    &lt;mx:states&gt;
        &lt;mx:State name="mammal"&gt;
            &lt;mx:AddChild position="lastChild"&gt;
                &lt;mx:FormItem label="Fur length"&gt;
                    &lt;mx:TextInput text="{Mammal(animal).furLength}"/&gt;
                &lt;/mx:FormItem&gt;
            &lt;/mx:AddChild&gt;
        &lt;/mx:State&gt;
    &lt;/mx:states&gt;
&lt;/mx:Form&gt;</pre>
<p>The animal variable is set when an element is selected from a list. It can be an instance of a custom class Mammal or Bird which extends the Animal class. The state also changes according to the type selected. The problem occurs when I select a non-Mammal. The binding will execute, expecting a Mammal for the TextInput&#8217;s text property. An error will be thrown saying that Bird (or other) could not convert to Mammal. This is to be expected, as the TextInput in question remains on the stage even if the state is invisible.</p>
<p>What&#8217;s the solution? Perhaps not the most neat, but it works: create extra variables for every type. Now you will have animal:Animal, mammal:Mammal and bird:Bird variables with their respective types. When an animal is selected, every type except the needed one is set to null. The animal variable still points to the selected animal. The MXML changes:</p>
<pre class="brush:xml">&lt;mx:TextInput text="{mammal.furLength}"/&gt;</pre>
<p>What happens? When the bindings execute, if a Mammal is selected, the mammal variable is equal to a Mammal instance and everything is smooth. If a Bird is selected, the mammal variable is null and everything is smooth again. Hurray! It took me about 2 hours to figure out. If you have a better solution, please share.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/as3-data-binding-and-component-states/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

