<?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>Thinking in Code &#187; scope</title>
	<atom:link href="http://www.michelboudreau.com/tags/scope/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michelboudreau.com</link>
	<description>Michel Boudreau&#039;s Personal Blog</description>
	<lastBuildDate>Wed, 25 Apr 2012 20:18:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Repeater Scope &#8211; Flex Silently Failing</title>
		<link>http://www.michelboudreau.com/2009/12/11/repeater-scope-flex-silently-failing/</link>
		<comments>http://www.michelboudreau.com/2009/12/11/repeater-scope-flex-silently-failing/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 20:13:41 +0000</pubDate>
		<dc:creator>Michel Boudreau</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[repeater]]></category>
		<category><![CDATA[scope]]></category>
		<category><![CDATA[silent fail]]></category>
		<category><![CDATA[this]]></category>

		<guid isPermaLink="false">http://www.michelboudreau.com/?p=207</guid>
		<description><![CDATA[This specific problem has been annoying me for a while.  ...]]></description>
			<content:encoded><![CDATA[<p>This specific problem has been annoying me for a while.  I personally don&#8217;t like using Repeaters, they aren&#8217;t the best way to handle the repetition of a specific element and also, they can cause memory leaks if not used properly.  When I do use them, it&#8217;s because I&#8217;m creating a prototype or in a time crunch.</p>
<p><span id="more-207"></span></p>
<p>I use the &#8216;this&#8217; keyword a good amount in my code.  I like it because it differentiates in a quick and effective matter that the current variable being referenced is a class variable and not a function variable.   However, if you have the following:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;mx:Repeater id=&quot;rp&quot; dataProvider=&quot;this._repeaterData&quot; &gt;
	&lt;custom:SomeComponent dataProvider=&quot;{this._data}&quot; /&gt;
&lt;/mx:Repeater&gt;
</pre>
<p>In this example, we have a Repeater using &#8216;this._repeaterData&#8217;, that is repeating a &#8216;SomeComponent&#8217; component that binds the &#8216;this._data&#8217; variable.  Most of you would think that this works since the variable in your class is available and that the compiler is not giving any errors.  However, when you try this example, you will notice that what you set in the &#8216;this._data&#8217; isn&#8217;t binding properly to the component.  Why is that?</p>
<p>This would be the work of the Repeater.  Flex doesn&#8217;t let you know about this flaw, but whatever is within the Repeater tag changes the scope of the &#8216;this&#8217; keyword.  In this case, the &#8216;this&#8217; keyword points to the Repeater itself and no errors actually occur even though there should be one.  You are left debugging this small piece of code for the longest time until you notice that removing the &#8216;this&#8217; keyword within the Repeater actually fixes this problem.  In fact, this bit of code actually works:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;mx:Repeater id=&quot;rp&quot; dataProvider=&quot;this._repeaterData&quot; &gt;
	&lt;custom:SomeComponent dataProvider=&quot;{_data}&quot; /&gt;
&lt;/mx:Repeater&gt;
</pre>
<p>It works because of the way Flash looks for variables within a scope (which is another subject altogether).  This is a pretty big flaw in the compiler which can cause a lot of grief and hopefully will be fixed in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michelboudreau.com/2009/12/11/repeater-scope-flex-silently-failing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/8 queries in 0.003 seconds using disk: basic
Object Caching 298/298 objects using disk: basic

Served from: www.michelboudreau.com @ 2012-05-21 07:25:26 -->
