While loop slowing down flash - need some schooling

here’s my code:

var foodArray = new Array();
var loopCounter = 0;
var newNum;
 
while (loopCounter <= 6) {
 
 newNum = Math.floor(Math.random()*6);
 
 if (foodArray.toString().indexOf(newNum) == -1) {
  foodArray[loopCounter] = newNum;
  trace (foodArray[loopCounter]);
  loopCounter++
 }
 
};

I’m just trying to randomly generate #'s 0-5 to different spots in my ‘foodArray’. Which is working fine, when I’m doing the trace I get 0 through 5 in different spots and non-repeating.

But I get this problem in flash when I test or view the external .swf:

“A script in this movie is causing Flash Player to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?” Then two buttons, “Yes” and “No”.

When I click “Yes” the swf plays and my numbers in my array trace out non-repeating, the way I want, but the rest of my movie behaves funky.

Thanks for any help. :wink: