Actionscript 2 and Recursion
I stumbled upon a little limit in Flash today….. If you decide to use recursion as a means to tackle a problem in Flash, you had better be sure that under no circumstances the function recurse more than 256 times. If your function recurses 256 times the movie will crash completely and all ActionScript will stop executing. As usual this failure is silent, so be extremely careful if you do decide to use recursion. Keep in mind that this limitation isn’t function specific. For example, if you’re doing recursion with multiple functions you will reach the limit as soon as the Flash application gets 256 levels deep.
Now, on the surface most programmers would say that any function that needs to recurse more than 256 times is simply bad code. Generally I agree with this, although I’m sure you can find an exception if you look hard enough.
Recent Comments