Actionscript running ahead of itself

Problem, everytime I try to use a structure as seen in this code snippet, the code fails because Flash runs ahead and executes code that isn’t meant to be executed yet.
The checkQueue*.map is an array part of an object, which I’m trying to pass to the startfillMap() function which then does the appropriate stuff with it. However, once the program enters the If function, the object has already been removed, thus an undefined value is passed to startfillMap(), resulting in failure.

Does anybody know how to fix this so it executes the “checkQueue.splice(i, 1);” only after everything in front of it has been dealt with? That would be a huge help,

thanks

note: without the “If” the code does work


if(!colCheck(checkQueue*.map)){
startfillMap(checkQueue*.map);
};
 
checkQueue.splice(i, 1);
checkNum--;
 
break;