recursive functions in flash

  • Started
  • Last post
  • 1 Response
  • bry

    i'm trying to write a recursive function that searches through a 2d array and branches out using multiple simultaneous recursive calls but it doesn't seem to be working.

    either i suck at coding or macromedia placed limitations on recursive calls.

    here's a heavily simplified version of the code:
    -----------------
    function array_do(x, y) {
    // snip
    if (condition1 == true) {
    array_do(x-1, y);
    }
    if (condition2 == true) {
    array_do(x+1, y);
    }
    if (condition3 == true) {
    array_do(x, y-1);
    }
    if (condition4 == true) {
    array_do(x, y+1);
    } // note: no 'else' statements, so all 4 conditions can be met
    }

    btw what i'm trying to do is find the largest collection of adjacent matching elements starting from an arbritary starting point in the 2-d array. if anyone can point me to a better algorithm then that would be awesome.

    just wondering if someone could help me out here. thanks =)

  • bry0

    whoops..
    forgot to mention that if one of the conditions are met, it's as if it makes the recursive call but seems to skip any of the code after where the condition was met.