<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: An ActionScript 3.0 Recursion Excursion</title>
	<atom:link href="http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/</link>
	<description>OOP Techniques for Flash and Flex Developers</description>
	<lastBuildDate>Wed, 10 Mar 2010 17:32:01 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bill Sanders</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-865</link>
		<dc:creator>Bill Sanders</dc:creator>
		<pubDate>Tue, 04 Nov 2008 20:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-865</guid>
		<description>Hi Michael,

Refactoring a recursive function sounds interesting. We&#039;d love to see an example of how you do that in ActionScript 3.0.

Thanks,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Michael,</p>
<p>Refactoring a recursive function sounds interesting. We&#8217;d love to see an example of how you do that in ActionScript 3.0.</p>
<p>Thanks,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-861</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Thu, 30 Oct 2008 09:43:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-861</guid>
		<description>Hi Rolf,

The point you make is certainly valid and it&#039;s probably one I should have included. However, the Fibonacci is used to illustrate how recursion works, and while it is not the most efficient way to generate a Fibonacci sequence, it reveals the nature of the recursive function.

Of course you are quite right, though, that a recursive function is not the best way to generate a Fibonacci value. It&#039;s just a fun way to show recursion.

Thanks for your insightful comment,
Bill</description>
		<content:encoded><![CDATA[<p>Hi Rolf,</p>
<p>The point you make is certainly valid and it&#8217;s probably one I should have included. However, the Fibonacci is used to illustrate how recursion works, and while it is not the most efficient way to generate a Fibonacci sequence, it reveals the nature of the recursive function.</p>
<p>Of course you are quite right, though, that a recursive function is not the best way to generate a Fibonacci value. It&#8217;s just a fun way to show recursion.</p>
<p>Thanks for your insightful comment,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Schmalle</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-857</link>
		<dc:creator>Michael Schmalle</dc:creator>
		<pubDate>Wed, 29 Oct 2008 12:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-857</guid>
		<description>Hi,

I really think this issue boils down to design. When an application is designed from the base up, constraints are found and implemented into the design.

I work with recursive functions quite a bit, Flash 5 -&gt; now. When you run into problems with this is when you are creating a call stack that involves other methods being called indirectly from a recursive method.

IE dispatchEvent() is dangerous in a recursive method.

Once you get experience with the limits of the engine that runs your code (IE Flash Player), you know intuitively where the red line is and don&#039;t even attempt some things (switch from defense to offense).

A lot of the time a recursive function can be refactored into a batch or other related pattern.

Experience gives forward vision and allows an abstract view before any emergency in code throws a stack overflow.

Mike</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I really think this issue boils down to design. When an application is designed from the base up, constraints are found and implemented into the design.</p>
<p>I work with recursive functions quite a bit, Flash 5 -&gt; now. When you run into problems with this is when you are creating a call stack that involves other methods being called indirectly from a recursive method.</p>
<p>IE dispatchEvent() is dangerous in a recursive method.</p>
<p>Once you get experience with the limits of the engine that runs your code (IE Flash Player), you know intuitively where the red line is and don&#8217;t even attempt some things (switch from defense to offense).</p>
<p>A lot of the time a recursive function can be refactored into a batch or other related pattern.</p>
<p>Experience gives forward vision and allows an abstract view before any emergency in code throws a stack overflow.</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rolf vreijdenberger</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-852</link>
		<dc:creator>rolf vreijdenberger</dc:creator>
		<pubDate>Tue, 28 Oct 2008 17:29:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-852</guid>
		<description>nice article, but let me point out two things:

the fibonacci example above is the (no diss intended) naive way as it takes exponential time to compute as each recursion needs to calculate the whole sequence of numbers before it -recursively- (in the statement return fibo(r-1) + fibo(r-2); )
not nice ;)
Fibonacci is a case of a problem that can be handled generically with dynamic programming (or memoization), in which you would store the previous calculated output (for fibonacci, this can easily be done in an array to avoid recomputation. Making this change lets the calculation execute in lineair time !!!

Also, as the numbers grow exponentially, values grow very fast.
fibo(45) is actually the largest number that can be represented by a 32 bit integer!</description>
		<content:encoded><![CDATA[<p>nice article, but let me point out two things:</p>
<p>the fibonacci example above is the (no diss intended) naive way as it takes exponential time to compute as each recursion needs to calculate the whole sequence of numbers before it -recursively- (in the statement return fibo(r-1) + fibo(r-2); )<br />
not nice ;)<br />
Fibonacci is a case of a problem that can be handled generically with dynamic programming (or memoization), in which you would store the previous calculated output (for fibonacci, this can easily be done in an array to avoid recomputation. Making this change lets the calculation execute in lineair time !!!</p>
<p>Also, as the numbers grow exponentially, values grow very fast.<br />
fibo(45) is actually the largest number that can be represented by a 32 bit integer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: localToGlobal &#187; Blog Archive &#187; news review -&#62; 43th week of 2008</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-851</link>
		<dc:creator>localToGlobal &#187; Blog Archive &#187; news review -&#62; 43th week of 2008</dc:creator>
		<pubDate>Fri, 24 Oct 2008 14:42:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-851</guid>
		<description>[...] &gt; An ActionScript 3.0 Recursion Excursion &#124; ActionScript 3 Design Patterns [...]</description>
		<content:encoded><![CDATA[<p>[...] &gt; An ActionScript 3.0 Recursion Excursion | ActionScript 3 Design Patterns [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-850</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Fri, 24 Oct 2008 11:39:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-850</guid>
		<description>Hey Alex,

Thanks for taking the time on that. Love those Fibonacci sequences!

Kindest regards,
Bill</description>
		<content:encoded><![CDATA[<p>Hey Alex,</p>
<p>Thanks for taking the time on that. Love those Fibonacci sequences!</p>
<p>Kindest regards,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrSteel</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-849</link>
		<dc:creator>MrSteel</dc:creator>
		<pubDate>Fri, 24 Oct 2008 11:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-849</guid>
		<description>yep, solution can be to use a recursion with a timer :)

&lt;pre lang=&quot;actionscript&quot;&gt;package {
	import flash.display.Sprite;
	
	/**
	 * @author alex.gvozden
	 */
	public class Recursion extends Sprite {
		
		private var _fib : Number = 0;
		private var _fib2 : Number = 1;
		private var _maxLevel : Number = 2050;
		
		public function Recursion() {
			fibonacci(0);
		}
		
		private function fibonacci(level : Number) : void {
			
			trace(&quot;level : &quot; + level + &quot; &quot; + _fib);
			_fib2 += _fib;
			_fib = _fib2-_fib;
			level++;
			if (level &lt; _maxLevel)
				fibonacci(level);
					
		}
	}
}&lt;/pre&gt;
&lt;code&gt;level : 1112 1.10858999763490e+232
[Fault] exception, information=undefined
Fault, fibonacci() at Recursion.as:24
&lt;/code&gt;

it&#039;s pretty good looking how it was before fp10, I think even 9 had lower limits
so yep recursion is great thing, should be used carefully but in flash you don&#039;t need hardcore recusion, and with simple one you can gain a lot
goin from recursion to iteration is important step in learning programming anyway, at least it helped me a lot on complex algebra problems</description>
		<content:encoded><![CDATA[<p>yep, solution can be to use a recursion with a timer :)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p256code1'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2561"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p256code1"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">/**
	 * @author alex.gvozden
	 */</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Recursion <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fib : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fib2 : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _maxLevel : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">2050</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Recursion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			fibonacci<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> fibonacci<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">level</span> : <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;level : &quot;</span> + <span style="color: #0066CC;">level</span> + <span style="color: #ff0000;">&quot; &quot;</span> + _fib<span style="color: #66cc66;">&#41;</span>;
			_fib2 += _fib;
			_fib = _fib2-_fib;
			<span style="color: #0066CC;">level</span>++;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">level</span> <span style="color: #66cc66;">&amp;</span>lt; _maxLevel<span style="color: #66cc66;">&#41;</span>
				fibonacci<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">level</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><code>level : 1112 1.10858999763490e+232<br />
[Fault] exception, information=undefined<br />
Fault, fibonacci() at Recursion.as:24<br />
</code></p>
<p>it&#8217;s pretty good looking how it was before fp10, I think even 9 had lower limits<br />
so yep recursion is great thing, should be used carefully but in flash you don&#8217;t need hardcore recusion, and with simple one you can gain a lot<br />
goin from recursion to iteration is important step in learning programming anyway, at least it helped me a lot on complex algebra problems</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-848</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Fri, 24 Oct 2008 08:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-848</guid>
		<description>Mr Steel and Gropapa,

Thank you for your comments. I had not considered the impact of a recursive function on the timeline. One of the main reasons I prefer to subclass to the Sprite class and not the MovieClip class is that the former has no timeline. The nice thing about Flash/Flex with ActionScript 3.0 is that you can choose to use the Timeline or not.

Would either of you be interested in providing an example of where a recursive function runs into problems with the Timeline? Or how you might use a recursive function with a timer?

Thank you both for your insights,
Bill</description>
		<content:encoded><![CDATA[<p>Mr Steel and Gropapa,</p>
<p>Thank you for your comments. I had not considered the impact of a recursive function on the timeline. One of the main reasons I prefer to subclass to the Sprite class and not the MovieClip class is that the former has no timeline. The nice thing about Flash/Flex with ActionScript 3.0 is that you can choose to use the Timeline or not.</p>
<p>Would either of you be interested in providing an example of where a recursive function runs into problems with the Timeline? Or how you might use a recursive function with a timer?</p>
<p>Thank you both for your insights,<br />
Bill</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gropapa</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-847</link>
		<dc:creator>gropapa</dc:creator>
		<pubDate>Fri, 24 Oct 2008 06:31:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-847</guid>
		<description>hi mrSteel,
recursion may be dangerous in term of animation but sometimes you need id... so the answer would be that if you need your result right now just do it this way, otherwise you could use a timer or an enter frame listener so the animation can go smoothly during the recursive function call
nice article btw</description>
		<content:encoded><![CDATA[<p>hi mrSteel,<br />
recursion may be dangerous in term of animation but sometimes you need id&#8230; so the answer would be that if you need your result right now just do it this way, otherwise you could use a timer or an enter frame listener so the animation can go smoothly during the recursive function call<br />
nice article btw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrSteel</title>
		<link>http://www.as3dp.com/2008/10/23/an-actionscript-30-recursion-excursion/comment-page-1/#comment-846</link>
		<dc:creator>MrSteel</dc:creator>
		<pubDate>Fri, 24 Oct 2008 05:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=256#comment-846</guid>
		<description>nice article,
anyway, recursion is very dangerous with Flash platform because all script is executed per frame, so if you do deep recursion you can get your flash stucked... that&#039;s why flash limit of 256 levels of recursion

also, important thing is that any recursion can be transformed to iteration function, which needs a little bit more writing but it&#039;s very nice programming problem</description>
		<content:encoded><![CDATA[<p>nice article,<br />
anyway, recursion is very dangerous with Flash platform because all script is executed per frame, so if you do deep recursion you can get your flash stucked&#8230; that&#8217;s why flash limit of 256 levels of recursion</p>
<p>also, important thing is that any recursion can be transformed to iteration function, which needs a little bit more writing but it&#8217;s very nice programming problem</p>
]]></content:encoded>
	</item>
</channel>
</rss>
