In what manner does functions execute?

Hi!

For my application, I have to construct 20 large sprites filled with dynamically created contents.

Each construction of a sprite is pretty extensive, and just making a for loop pretty much makes my player crash.

So I was thinking of pacing my function execution with a timer and a switch list, but then I had another idea. What if I have a function with a switch list in it, and each case first creates a sprite, then call the function, telling it to run the next case on the list? Like this:

function setup(x){
  switch (x) {
    case 0:
      create_sprite();
      setup(1);
    break;
    case 1:
      create_sprite();
      setup(2);
    break;
    .
    .
    .
  }
}

Would that cause the functions to execute only after the previous one is done, or am I wasting my time here? Does that happen anyway, even in a for loop, or with a timer?

/ Frank