Thanks for the tips! It seems I found a much simpler way of doing it though, which I have posted below.
Code:
isoRadians = 30 * Math.PI / 180;
verticalDistance = 40;
horizontalDistance = Math.cos(isoRadians) * verticalDistance;
pegNum = 1;
for (i = 0; i < 10; i++){
for (j = 0; j < 10; j++){
this.attachMovie("peg","peg"+pegNum, pegNum, {_x:i*horizontalDistance, _y:j*verticalDistance});
if (i%2){
this["peg"+pegNum]._y += verticalDistance/2;
}
pegNum++;
}
}
OR
Code:
isoRadians = 30 * Math.PI / 180;
horizontalDistance = 40;
verticalDistance = Math.tan(isoRadians) * horizontalDistance * 2;
pegNum = 1;
for (i = 0; i < 10; i++){
for (j = 0; j < 10; j++){
this.attachMovie("peg","peg"+pegNum, pegNum, {_x:i*horizontalDistance, _y:j*verticalDistance});
if (i%2){
this["peg"+pegNum]._y += verticalDistance/2;
}
pegNum++;
}
}
I used this page to understand the logic of an isometric grid and this page to snag the math. The source code of the latter is great because it covers almost every situation where you know only a handful of attributes of a triangle.