# Recursive function (just sharing)

**URL:** <https://forum.kirupa.com/t/recursive-function-just-sharing/317628>\
**Category:** flash\
**Created:** [December 28, 2010, 6:30am UTC](https://forum.kirupa.com/t/recursive-function-just-sharing/317628 "2010-12-28T06:30:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lnsiu](https://avatars.discourse-cdn.com/v4/letter/l/9fc29f/32.png) [@lnsiu](https://forum.kirupa.com/u/lnsiu)\
**Post date:** [December 28, 2010, 6:30am UTC](https://forum.kirupa.com/t/recursive-function-just-sharing/317628/1 "2010-12-28T06:30:24Z")

</div>

For some reason I never had to do recursive functions, so when I finally had to do some, I was baffled I never learned it before. :cyclops:

ie, this is in educational purpose only - an ordinary for loop - rewritten as a recursive function.

(I had to use the recursive function to parse unknown object loop sizes)

```auto
function forloop():void
{
	var i=0;
	function loop():void
	{
		if(i<100)
		{
			//do something
			trace("current i: " + i );
			i++;
			loop();
		}else{
			trace("done");
		}
	}
	loop();
}
forloop()

```
