determining movie clip positioning on a dynamically created grid
I followed this tutorial to place my movie clips into grid positions. Each movie clip contains a text with their respective numbers. I want to be able to determine which movie clips are on the leftmost and rightmost column using an if statement. I was able to determine the top, bottom, and corner movie clips but I can't figure out how to check for leftmost and rightmost. In this example, movie clips 4 and 7 are leftmost while 6 and 9 are rightmost but I need a code to determine the leftmost and rightmost even when the number of movie clips in the grid are changed. I hope my explanation is clear enough. I would appreciate any help. Thank you.
Here's the code i have:
var tileCount:int = 12;
var rowCount:int = 4;
var colCount:int = tileCount/rowCount;
var col:int = 0;
var row:int = 0;
var space:Number = 2;
for (var i:int = 0; i < tileCount; i++){
col = i % colCount;
row = int(i/colCount);
var mc:MovieClip = new box();
mc.txt.text = i+1;
mc.x = (mc.width + space) * col;
mc.y = (mc.height + space) * row;
addChild(mc);
if ((mc.txt.text == rowCount/rowCount)||(mc.txt.text == colCount)||(mc.txt.text == tileCount-colCount+1)||(mc.txt.text == tileCount)){
mc.gotoAndStop("corner");
}else if ((mc.txt.text < colCount) && (mc.txt.text > 1)){
mc.gotoAndStop("topEdge");
}else if ((mc.txt.text < tileCount) && (mc.txt.text > tileCount-colCount+1)){
mc.gotoAndStop("bottomEdge");
}
}
