Actionscript Code:
function drawHexMap(map, storageMap, tileS, borderX, borderY){
//the map that should be passed is a 2d array of ints, containing how the hex map will be laid out
var tile, depth;
for(var i = 0; i < map.length; i++){
for(var j = 0; j < map[0].length; j++){
depth = _root.getNextHighestDepth();
tile = _root.attachMovie("hex_tile","HT:"+i+","+j, depth);
depth = tileS / tile._width * 100; //re-use depth var
tile._xscale = tile._yscale = depth;
tile._x = borderX + (tileS*j + (i%2)*tileS/2);
tile._y = borderY + (i*tileS*(tile._width / tile._height));
tile.r = i; //row
tile.c = j; //col-
depth = map[i][j]; //re-use depth again
tile.gotoAndStop(depth + 1);
if(!storageMap[depth]) storageMap[depth] = [];
storageMap[depth][storageMap[depth].length] = tile;
}
}
}
Actionscript Code:
for(var i = 0; i < storageArray.length; i++){
for(var j = 0; j < storageArray[i].length; j++){
tempTile = storageArray[i][j]
trace(i+","+j+" \t["+tempTile+" ("+tempTile._x+", "+tempTile._y+") ].hitTest("+_xmouse+", "+_ymouse+", true) = "+ tempTile.hitTest(_xmouse,_ymouse,true));
if(tempTile.hitTest(_xmouse, _ymouse, true)){
tempTile._alpha = 50;
} else tempTile._alpha = 100;
}
}