# Do...while causing fatal crash

**URL:** <https://forum.kirupa.com/t/do-while-causing-fatal-crash/261336>\
**Category:** Uncategorized\
**Created:** [May 26, 2008, 4:13pm UTC](https://forum.kirupa.com/t/do-while-causing-fatal-crash/261336 "2008-05-26T16:13:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ubermeowmix](https://avatars.discourse-cdn.com/v4/letter/u/7cd45c/32.png) [@Ubermeowmix](https://forum.kirupa.com/u/Ubermeowmix)\
**Post date:** [May 26, 2008, 4:13pm UTC](https://forum.kirupa.com/t/do-while-causing-fatal-crash/261336/1 "2008-05-26T16:13:59Z")

</div>

Do…While loop causing fatal crash and I’ve got no idea why, can anybody give any tips?

function randomValue(dir){  
if(dir == “height”){  
var randomInt = Math.round(random(game.number\_tiles/5));  
}else{  
var randomInt = Math.round(random((game.number\_tiles/5)+1));  
}  
return randomInt;  
}

function checkLevelEmpty(){  
var currentRandomX = randomValue(‘width’);  
var currentRandomY = randomValue(‘height’);  
trace('Random X: ‘+currentRandomX+’, Random Y: '+currentRandomY);

```
if(level[currentRandomY][currentRandomX] != 2){
        currentFilledTiles++;
        level[currentRandomY][currentRandomX] = 2;
}else{
        trace('Try Again!');
}

```

}

currentFilledTiles = 0;  
// generate the random level array with misc placement  
do {  
checkLevelEmpty();  
}  
while (currentFilledTiles \<= game.number\_tiles);  
}

---

<div class="post-metadata">

**Author:** ![Ubermeowmix](https://avatars.discourse-cdn.com/v4/letter/u/7cd45c/32.png) [@Ubermeowmix](https://forum.kirupa.com/u/Ubermeowmix)\
**Post date:** [May 28, 2008, 7:30pm UTC](https://forum.kirupa.com/t/do-while-causing-fatal-crash/261336/2 "2008-05-28T19:30:09Z")

</div>

It still causes a nasty crash, I checked it by showing the output in the this.onEnterFrame = function(){ trace(bla); } method.

It’s cycling through the random numbers and never exceeding 12, it needs to get to 15! but never does. I need some way to check through the ones already done, dump them in an Array and check that first maybe? I’m drawing a blank at the moment.

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [May 30, 2008, 9:14pm UTC](https://forum.kirupa.com/t/do-while-causing-fatal-crash/261336/3 "2008-05-30T21:14:34Z")

</div>

try to narrow it down as best you can so you have the minimal code needed to reliably produce a crash.

Flash Player should never crash. If it does, it’s a bug and needs to be fixed.
