How to stop MCs from overlapping each other?
private function loadWishes():void {
for (i; i<myXMLList.length(); i++) {
cBox=new MovieClip();
checkOverlap(cBox);
addChild(cBox);
commentArray.push(cBox);
}
}
private function checkOverlap(wishB:MovieClip) {
wishB.x=Math.random()*stage.stageWidth;
wishB.y=Math.random()*stage.stageHeight;
for (var i:uint=0; i<commentArray.length; i++) {
if (wishB.hitTestObject(commentArray[i])) {
checkOverlap(wishB);
return false;
}
trace(commentArray.length);
}
}
This doesn't seems to be working cause the amount of it checking whether MC is overlapping is about the amount of MC on stage. how to make it keep checking till everything's fine?