<?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"
	>
<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>
	<pubDate>Wed, 20 Aug 2008 18:49:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Dru</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#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>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'd use this new class with an the-event-listener-removes-the-event example?</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-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>NOTE: THE CODE WAS CUT OFF! 

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);
    };</description>
		<content:encoded><![CDATA[<p>NOTE: THE CODE WAS CUT OFF! </p>
<p>the first line of this function is added<br />
 var fProxy:Function = function():Void {<br />
      aParameters[aParameters.length] = fProxy;<br />
	  var aActualParameters:Array = arguments.concat(aParameters);<br />
      fFunction.apply(oTarget, aActualParameters);<br />
    };</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tonypee</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#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>If you modify Joey'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:

class com.ascb.util.Proxy {

  public static function create(oTarget:Object, fFunction:Function):Function {

    var aParameters:Array = new Array();
    for(var i:Number = 2; i </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>
<p>    var aParameters:Array = new Array();<br />
    for(var i:Number = 2; i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#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>Nice work!

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.

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 &#38; dynamic appending. I recently added to the post to include a version after reading this blog post and another.

If you are interested, check it out over at http://www.justgooddesign.com/blog/jgdelegate.htm</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-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>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.

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.</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-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>Hi,

Very interesting article because it hits right on an area I'm concerned about in my application. Perhaps you might be able to help me and others with a similar problem with your obvious expertise.

Say I have a video player (FLVPlayback) and a button that loads videos into it from a list of videos using the following function:

	public function playVideo(vid:String):Void{		
	
		my_FLVPlayback.contentPath = vid;
		my_FLVPlayback.addEventListener("complete", Delegate.create(this, onVidComplete));

	}

Do I need to remove the previous event listener each time the button is hit and a new video is loaded? If I don't will there be "memory leak" or an accumulation of listeners on my_FLVPlayback?

Seems if this is the case, your class will be a big help.
Thanks,
Micahael</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>
<p>	public function playVideo(vid:String):Void{		</p>
<p>		my_FLVPlayback.contentPath = vid;<br />
		my_FLVPlayback.addEventListener(&#8221;complete&#8221;, Delegate.create(this, onVidComplete));</p>
<p>	}</p>
<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.<br />
Thanks,<br />
Micahael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#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>Ronnie: It's hard to explain if you don't understand the Flash scope chain. If you haven't already, you might want to read &lt;a href="http://timotheegroleau.com/Flash/articles/scope_chain.htm" rel="nofollow"&gt;this article&lt;/a&gt; first.

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'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;.</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>
	<item>
		<title>By: Ronnie</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#comment-545</link>
		<dc:creator>Ronnie</dc:creator>
		<pubDate>Wed, 28 Sep 2005 19:48:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-545</guid>
		<description>Hi Steve, can you explain how does the latest version actually helps resolve Michael's concerns about the garbage collection? 

Thanks a lot :)</description>
		<content:encoded><![CDATA[<p>Hi Steve, can you explain how does the latest version actually helps resolve Michael&#8217;s concerns about the garbage collection? </p>
<p>Thanks a lot <img src='http://dynamicflash.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#comment-494</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Sat, 03 Sep 2005 19:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-494</guid>
		<description>Micheal: This has been solved with the latest version of the Delegate class. I'll blog about this when I get time, but for now you can download it from &lt;a href="http://dynamicflash.com/classes/Delegate.as" rel="nofollow"&gt;here&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Micheal: This has been solved with the latest version of the Delegate class. I&#8217;ll blog about this when I get time, but for now you can download it from <a href="http://dynamicflash.com/classes/Delegate.as" rel="nofollow">here</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Barry</title>
		<link>http://dynamicflash.com/2005/02/delegate-class-refined/#comment-382</link>
		<dc:creator>Michael Barry</dc:creator>
		<pubDate>Mon, 15 Aug 2005 14:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.dynamicflash.co.uk/2005/02/delegate-class-refined/#comment-382</guid>
		<description>Where does the anonymous function that is created get placed on the actionscript's scope chain in this Delegate implementation?  I have had problems in the past with creating nested anonymous functions that never get garbage collected after they are called.  This eventually turns into huge performace hit the longer the application is used.  http://timotheegroleau.com/Flash/articles/scope_chain.htm

Is there anyway to retain scope in a handler function and still evade this performance hit?</description>
		<content:encoded><![CDATA[<p>Where does the anonymous function that is created get placed on the actionscript&#8217;s scope chain in this Delegate implementation?  I have had problems in the past with creating nested anonymous functions that never get garbage collected after they are called.  This eventually turns into huge performace hit the longer the application is used.  <a href="http://timotheegroleau.com/Flash/articles/scope_chain.htm" rel="nofollow">http://timotheegroleau.com/Flash/articles/scope_chain.htm</a></p>
<p>Is there anyway to retain scope in a handler function and still evade this performance hit?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
