5 Replies Latest reply on Aug 24, 2012 12:34 PM by prodigalmaster

# 256 levels of recursion were exceeded in one action list

Hi,

How can i overcome the recursive function restriction. As it has a restriction of 256, i can't proceed further.  I need to increase the recursive level. How can i do it..?

Regards,

Kameshwaran A.

• ###### 1. Re: 256 levels of recursion were exceeded in one action list

It's not that it cannot do more than 256 levels of recursion, it is that your code doesn't stop the recursion, meaning it detects it will go on for infinity, so it stops it at 256. You need to have a condition which will stop the subroutine/function being called. E.g. have a counter add up each time the function is called and have an if statement which if the counter is less than 2048 or whatever you want will execute the recursive function,otherwise do nothing.

• ###### 2. Re: 256 levels of recursion were exceeded in one action list

Correct me if i am wrong.

I have made a small sample in which the function executes only 256 times

but i need that to be run for atleast 1000 times. how to make it.

var i:Number = 0;

Lbar();

function Lbar()

{

trace("abc");

abc();

def();

ghi();

i++;

if(i<= 1000)

{

trace(i)

Lbar();

}

}

function abc()

{

trace("abc");

// Somelines of code

}

function def()

{

trace("def");

// Somelines of code

}

function ghi()

{

trace("ghi");

// Somelines of code

}

• ###### 3. Re: 256 levels of recursion were exceeded in one action list

Is it absolutelly nessesary to use recursion? Couldn't you do:

for(i=0;i<1000;i++){

Lbar();

}

• ###### 4. Re: 256 levels of recursion were exceeded in one action list

Yes, reason is i will be having sendAndLoad function.

What i will be doing is, i will be copying n number of particualar area in images which ever i got as a input. So, i will be loading the image inbetween the function run. if i use for loop, before loading the image loop will execute. Thats the  problem of using the forloop.

• ###### 5. Re: 256 levels of recursion were exceeded in one action list

I believe that does not make sense.

If you call a function within itself, it will execute again until the condition is met (like a for loop) and will then do the rest of the code in the function (for each time it was called) (put a trace after the function call to see this).

So if you use a for loop, to get the exact same thing to occur, make a conditional of the code you do not wish to execute until the first part has been execute n times.