<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Delegate class refined</title>
	<atom:link href="http://dynamicflash.com/2005/02/delegate-class-refined/feed/" rel="self" type="application/rss+xml" />
	<link>http://dynamicflash.com/2005/02/delegate-class-refined/</link>
	<description>Confessions of a serial code abuser</description>
	<lastBuildDate>Wed, 16 Dec 2009 20:40:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: clark</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-75744</link>
		<dc:creator>clark</dc:creator>
		<pubDate>Sun, 04 Jan 2009 19:27:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-75744</guid>
		<description>&lt;p&gt;hi there Steve and allothers,&lt;/p&gt;

&lt;p&gt;with regards to your code, what about the scenario i have described below, where there are 2 class listeners, which execute functions, however only the one function is supposed to remove both the eventListeners, how will your class handle this?
because the way i see it, you have a delegate function parameter passed into the function being called, but now if there are 2 eventListeners to remove what happens there? i sort of tried to do it this method with your code, am not getting it right, and not sure if any of my event listeners are being deleted...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
class Apple{
     public function Apple() {
            this.addEventListener(&quot;blue&quot;, Delegate.create(this, funcA);
            this.addEventListener(&quot;red&quot;, Delegate.create(this, funcB);
     }&lt;/p&gt;

&lt;p&gt;&lt;pre&gt;&lt;code&gt; public function funcA(event:Object) {
        //do somehing
 }&lt;/p&gt;

&lt;p&gt;public function funcB(event:Object) {
         this.removeEventListener(&quot;blue&quot;, Delegate.create(this, funcA);
        this.removeEventListener(&quot;red&quot;, Delegate.create(this, funcB);&lt;br /&gt;
 }
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;}
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;thanks
clarklin&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>hi there Steve and allothers,</p>

<p>with regards to your code, what about the scenario i have described below, where there are 2 class listeners, which execute functions, however only the one function is supposed to remove both the eventListeners, how will your class handle this?
because the way i see it, you have a delegate function parameter passed into the function being called, but now if there are 2 eventListeners to remove what happens there? i sort of tried to do it this method with your code, am not getting it right, and not sure if any of my event listeners are being deleted&#8230;</p>

<p><code>
class Apple{
     public function Apple() {
            this.addEventListener("blue", Delegate.create(this, funcA);
            this.addEventListener("red", Delegate.create(this, funcB);
     }</code></p>

<p><pre><code> public function funcA(event:Object) {
        //do somehing
 }</code></pre></p>

<p>public function funcB(event:Object) {
         this.removeEventListener("blue", Delegate.create(this, funcA);
        this.removeEventListener("red", Delegate.create(this, funcB);<br />
 }
</p>

<p>}
</p>

<p>thanks
clarklin</p>]]></content:encoded>
	</item>
	<item>
		<title>By: juicyland</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-61064</link>
		<dc:creator>juicyland</dc:creator>
		<pubDate>Sun, 21 Sep 2008 22:59:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-61064</guid>
		<description>&lt;p&gt;ibm we australia home yahoo boat girl&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>ibm we australia home yahoo boat girl</p>]]></content:encoded>
	</item>
	<item>
		<title>By: whitereddayd</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-61001</link>
		<dc:creator>whitereddayd</dc:creator>
		<pubDate>Sun, 21 Sep 2008 14:46:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-61001</guid>
		<description>&lt;p&gt;house minor apple busy day girl juicy sun all night usa&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>house minor apple busy day girl juicy sun all night usa</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Dru</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-25100</link>
		<dc:creator>Dru</dc:creator>
		<pubDate>Fri, 14 Sep 2007 20:18:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-25100</guid>
		<description>&lt;p&gt;Am I missing something, or does this only work if you want to remove the event listener in an event?  What if I want to remove the listener at a completely different time, like in an onUnload?  Seems like the only way to handle that is the first option outlined above.  I like the idea of simple and elegant solutions, but someone please explain how I&#039;d use this new class with an the-event-listener-removes-the-event example?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Am I missing something, or does this only work if you want to remove the event listener in an event?  What if I want to remove the listener at a completely different time, like in an onUnload?  Seems like the only way to handle that is the first option outlined above.  I like the idea of simple and elegant solutions, but someone please explain how I&#8217;d use this new class with an the-event-listener-removes-the-event example?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: tonypee</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-17697</link>
		<dc:creator>tonypee</dc:creator>
		<pubDate>Fri, 16 Mar 2007 01:49:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-17697</guid>
		<description>&lt;p&gt;NOTE: THE CODE WAS CUT OFF!&lt;/p&gt;

&lt;p&gt;the first line of this function is added
 var fProxy:Function = function():Void {
      aParameters[aParameters.length] = fProxy;
      var aActualParameters:Array = arguments.concat(aParameters);
      fFunction.apply(oTarget, aActualParameters);
    };&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>NOTE: THE CODE WAS CUT OFF!</p>

<p>the first line of this function is added
 var fProxy:Function = function():Void {
      aParameters[aParameters.length] = fProxy;
      var aActualParameters:Array = arguments.concat(aParameters);
      fFunction.apply(oTarget, aActualParameters);
    };</p>]]></content:encoded>
	</item>
	<item>
		<title>By: tonypee</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-17696</link>
		<dc:creator>tonypee</dc:creator>
		<pubDate>Fri, 16 Mar 2007 01:47:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-17696</guid>
		<description>&lt;p&gt;If you modify Joey&#039;s Proxy class to always send a reference to the Proxy function (used to removeEventListener) then you dont need to save a reference to the object anywhere. Making it quite neat. modd:&lt;/p&gt;

&lt;p&gt;class com.ascb.util.Proxy {&lt;/p&gt;

&lt;p&gt;public static function create(oTarget:Object, fFunction:Function):Function {&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var aParameters:Array = new Array();
for(var i:Number = 2; i 
&lt;/code&gt;&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>If you modify Joey&#8217;s Proxy class to always send a reference to the Proxy function (used to removeEventListener) then you dont need to save a reference to the object anywhere. Making it quite neat. modd:</p>

<p>class com.ascb.util.Proxy {</p>

<p>public static function create(oTarget:Object, fFunction:Function):Function {</p>

<pre><code>var aParameters:Array = new Array();
for(var i:Number = 2; i 
</code></pre>]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-11639</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Thu, 07 Dec 2006 01:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-11639</guid>
		<description></description>
		<content:encoded><![CDATA[<p>Nice work!</p>

<p>I feel like if you add the reference to the arguments you are essentially polluting the function with extra information. At first glance this doesn’t seem very safe in those instances when you prefer to omit or null argument values.</p>

<p>My personal jgDelegate class was first expanded from the work at createage.com. Since then it has grown to include create, proxy, returns, overwriting, as well as static &amp; dynamic appending. I recently added to the post to include a version after reading this blog post and another.</p>

<p>If you are interested, check it out over at <a href="http://www.justgooddesign.com/blog/jgdelegate.htm" rel="nofollow">http://www.justgooddesign.com/blog/jgdelegate.htm</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-10127</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Sun, 19 Nov 2006 15:06:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-10127</guid>
		<description>&lt;p&gt;Michael: There is no need to worry about memory leaks in this instance. Since your event handler is attached to the FLVPlayback component instance you only need to attach it once, not every time you load a new video into that component.&lt;/p&gt;

&lt;p&gt;The memory leaks mentioned in this article and in the comments are made apparent when many Delegates are created. In the earlier version of this class the Delegate function would retain a reference to itself through the activation object at the top of the scope chain, and because there was a reference to it the delegate would never be garbage collected. This was fixed in version 1.0.1.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Michael: There is no need to worry about memory leaks in this instance. Since your event handler is attached to the FLVPlayback component instance you only need to attach it once, not every time you load a new video into that component.</p>

<p>The memory leaks mentioned in this article and in the comments are made apparent when many Delegates are created. In the earlier version of this class the Delegate function would retain a reference to itself through the activation object at the top of the scope chain, and because there was a reference to it the delegate would never be garbage collected. This was fixed in version 1.0.1.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-9922</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 17 Nov 2006 23:54:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-9922</guid>
		<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Very interesting article because it hits right on an area I&#039;m concerned about in my application. Perhaps you might be able to help me and others with a similar problem with your obvious expertise.&lt;/p&gt;

&lt;p&gt;Say I have a video player (FLVPlayback) and a button that loads videos into it from a list of videos using the following function:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public function playVideo(vid:String):Void{     

    my_FLVPlayback.contentPath = vid;
    my_FLVPlayback.addEventListener(&quot;complete&quot;, Delegate.create(this, onVidComplete));

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Do I need to remove the previous event listener each time the button is hit and a new video is loaded? If I don&#039;t will there be &quot;memory leak&quot; or an accumulation of listeners on my_FLVPlayback?&lt;/p&gt;

&lt;p&gt;Seems if this is the case, your class will be a big help.
Thanks,
Micahael&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi,</p>

<p>Very interesting article because it hits right on an area I&#8217;m concerned about in my application. Perhaps you might be able to help me and others with a similar problem with your obvious expertise.</p>

<p>Say I have a video player (FLVPlayback) and a button that loads videos into it from a list of videos using the following function:</p>

<pre><code>public function playVideo(vid:String):Void{     

    my_FLVPlayback.contentPath = vid;
    my_FLVPlayback.addEventListener("complete", Delegate.create(this, onVidComplete));

}
</code></pre>

<p>Do I need to remove the previous event listener each time the button is hit and a new video is loaded? If I don&#8217;t will there be &#8220;memory leak&#8221; or an accumulation of listeners on my_FLVPlayback?</p>

<p>Seems if this is the case, your class will be a big help.
Thanks,
Micahael</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/comment-page-1/#comment-547</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Wed, 28 Sep 2005 21:31:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-547</guid>
		<description>&lt;p&gt;Ronnie: It&#039;s hard to explain if you don&#039;t understand the Flash scope chain. If you haven&#039;t already, you might want to read &lt;a href=&quot;http://timotheegroleau.com/Flash/articles/scope_chain.htm&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt; first.&lt;/p&gt;

&lt;p&gt;It basically removes the circular reference from the activation object in the anonymous function and the anonymous function itself by making sure that the anonymous function doesn&#039;t actually make use of the activation object. Instead the necessary variables are attached to the Function object so it can reference then directly with &lt;code&gt;arguments.callee&lt;/code&gt;.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Ronnie: It&#8217;s hard to explain if you don&#8217;t understand the Flash scope chain. If you haven&#8217;t already, you might want to read <a href="http://timotheegroleau.com/Flash/articles/scope_chain.htm" rel="nofollow">this article</a> first.</p>

<p>It basically removes the circular reference from the activation object in the anonymous function and the anonymous function itself by making sure that the anonymous function doesn&#8217;t actually make use of the activation object. Instead the necessary variables are attached to the Function object so it can reference then directly with <code>arguments.callee</code>.</p>]]></content:encoded>
	</item>
</channel>
</rss>
