<?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: AS3 doLater/todo Function Queue</title>
	<atom:link href="http://blog.efnx.com/as3-dolatertodo-function-queue/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.efnx.com/as3-dolatertodo-function-queue/</link>
	<description>Would you like your piece of code or your pizza cold?</description>
	<lastBuildDate>Wed, 03 Mar 2010 08:02:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Schell</title>
		<link>http://blog.efnx.com/as3-dolatertodo-function-queue/comment-page-1/#comment-27</link>
		<dc:creator>Schell</dc:creator>
		<pubDate>Sun, 16 Dec 2007 13:21:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.efnx.com/?p=37#comment-27</guid>
		<description>Yes, I see that my toString() wouldn’t trace the list of functions in the order that they were listed, but without adding another variable to keep track of the order added, how would you trace or execute them first come first serve? It seems like the order it traces in is the same order it executes in.

      Another note: the interesting thing about this class isn’t how the methods are replaced, but because (contrary to posts I had read regarding the matter -&gt; http://gskinner.com/blog/archives/2006/07/as3_dictionary.html) I couldn’t create duplicate function entries with the same method (in a weakly referenced Dictionary).

      My main point was that changing the Dictionary’s reference (weak or strong) changes the output of the code I posted on your blog. For example, changing the code I had posted above to instantiate my Queue class with a ’strong’ referenced Dictionary, the output is as follows:

      object [Queue]
      -&gt; function Function() {} 3,5
      -&gt; function Function() {} 4,5
      8
      9
      object [Queue]
      done

      As you can see calling toString() on the class traces the contents (in whatever order it decides) and then executes the functions in that same order. Instantiating the class with a weakly referenced Dictionary results in the following:

      object [Queue]
      -&gt; function Function() {} 4,5
      -&gt; function Function() {} 3,5
      object [Queue]
      done

      Here you can see that immediately after pushing the functions into the Queue, the functions can be listed, but after the TimerEvent.TIMER (which is set to 1 millisecond) has triggered, the functions that were once listed are no longer there!

      I may be missing the point, but I never explicitly removed the functions from the queue, yet they disappeared. When the class is instantiated with a strong referenced Dictionary the functions last and are executed. I don’t know what else to attribute this behavior to besides the GC. Maybe you can help me understand this more clearly.</description>
		<content:encoded><![CDATA[<p>Yes, I see that my toString() wouldn’t trace the list of functions in the order that they were listed, but without adding another variable to keep track of the order added, how would you trace or execute them first come first serve? It seems like the order it traces in is the same order it executes in.</p>
<p>      Another note: the interesting thing about this class isn’t how the methods are replaced, but because (contrary to posts I had read regarding the matter -> <a href="http://gskinner.com/blog/archives/2006/07/as3_dictionary.html)" rel="nofollow">http://gskinner.com/blog/archives/2006/07/as3_dictionary.html)</a> I couldn’t create duplicate function entries with the same method (in a weakly referenced Dictionary).</p>
<p>      My main point was that changing the Dictionary’s reference (weak or strong) changes the output of the code I posted on your blog. For example, changing the code I had posted above to instantiate my Queue class with a ’strong’ referenced Dictionary, the output is as follows:</p>
<p>      object [Queue]<br />
      -> function Function() {} 3,5<br />
      -> function Function() {} 4,5<br />
      8<br />
      9<br />
      object [Queue]<br />
      done</p>
<p>      As you can see calling toString() on the class traces the contents (in whatever order it decides) and then executes the functions in that same order. Instantiating the class with a weakly referenced Dictionary results in the following:</p>
<p>      object [Queue]<br />
      -> function Function() {} 4,5<br />
      -> function Function() {} 3,5<br />
      object [Queue]<br />
      done</p>
<p>      Here you can see that immediately after pushing the functions into the Queue, the functions can be listed, but after the TimerEvent.TIMER (which is set to 1 millisecond) has triggered, the functions that were once listed are no longer there!</p>
<p>      I may be missing the point, but I never explicitly removed the functions from the queue, yet they disappeared. When the class is instantiated with a strong referenced Dictionary the functions last and are executed. I don’t know what else to attribute this behavior to besides the GC. Maybe you can help me understand this more clearly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mims Wright</title>
		<link>http://blog.efnx.com/as3-dolatertodo-function-queue/comment-page-1/#comment-22</link>
		<dc:creator>Mims Wright</dc:creator>
		<pubDate>Fri, 14 Dec 2007 18:04:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.efnx.com/?p=37#comment-22</guid>
		<description>Hi Schell, 

I was looking at the code you posted to my site. I wanted to make a few notes that may help out.

First, the order of the trace has to do with the for...in loop that you use in the toString() method. This loop doesn&#039;t necessarily output in the order you added the functions.

Second, this isn&#039;t happening as a result of weak references. As you mentioned on your blog post, you cannot use the same function twice as a key without overwriting the previous value. In a Dictionary, the key object acts the same as an index for an array. If you had 

var a:Array = new Array();
a[0] = &quot;foo&quot;;
a[1] = &quot;bar&quot;;
a[1] = &quot;woot&quot;;
trace(a); // foo,woot

so it stands to reason that you shouldn&#039;t be able to do this with functions as keys either.

Since this class essentially runs a list of functions one after the other, you may want to try using dynamic Functions instead. Something like this:

var func:Function = new Function ():void {
    blah (1, 5);
    blah (2, 5);
    blah (4, 5);
    blah2(3, 5);
}
func();

I hope that was helpful.</description>
		<content:encoded><![CDATA[<p>Hi Schell, </p>
<p>I was looking at the code you posted to my site. I wanted to make a few notes that may help out.</p>
<p>First, the order of the trace has to do with the for&#8230;in loop that you use in the toString() method. This loop doesn&#8217;t necessarily output in the order you added the functions.</p>
<p>Second, this isn&#8217;t happening as a result of weak references. As you mentioned on your blog post, you cannot use the same function twice as a key without overwriting the previous value. In a Dictionary, the key object acts the same as an index for an array. If you had </p>
<p>var a:Array = new Array();<br />
a[0] = &#8220;foo&#8221;;<br />
a[1] = &#8220;bar&#8221;;<br />
a[1] = &#8220;woot&#8221;;<br />
trace(a); // foo,woot</p>
<p>so it stands to reason that you shouldn&#8217;t be able to do this with functions as keys either.</p>
<p>Since this class essentially runs a list of functions one after the other, you may want to try using dynamic Functions instead. Something like this:</p>
<p>var func:Function = new Function ():void {<br />
    blah (1, 5);<br />
    blah (2, 5);<br />
    blah (4, 5);<br />
    blah2(3, 5);<br />
}<br />
func();</p>
<p>I hope that was helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Schell</title>
		<link>http://blog.efnx.com/as3-dolatertodo-function-queue/comment-page-1/#comment-21</link>
		<dc:creator>Schell</dc:creator>
		<pubDate>Tue, 11 Dec 2007 21:07:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.efnx.com/?p=37#comment-21</guid>
		<description>Let me add that while using this class it is very easy to see how methods stored in a weakly referenced Dictionary object are immediately collected.</description>
		<content:encoded><![CDATA[<p>Let me add that while using this class it is very easy to see how methods stored in a weakly referenced Dictionary object are immediately collected.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
