im new in as3 (as you can see) and im having some problems.
im creating a tile based game and im using something like this to draw the map:
for (y=0; y<=15; y++)
{
for (x=0; x<=19; x++)
{
var hex:tile = new tile();
hex.stop();
hex.x=(x*25)+13;
hex.y=(y*25)+13;
hex.gotoAndStop(map[y][x]);
hex.addEventListener(MouseEvent.CLICK,hexclick);
addChild(hex);
where tile is a Movieclip with several frames, 1 for each kind of tile used.
the engine takes the format of the map from an array called map (0,0,1,0,1,2,3, etc) and sets every tile (called “hex”) on the apropiate frame based on the “map” array data.
now, that part works like a charm, my problem is:
later on the code the user can “build” some structures on the grass tiles (hexes with the frame set to 1), i do this adding another child movieclip inside the hex movieclip, and that works too, what i need now is to change the frame on that hex from [1] to [20] (empty grass to occupied grass) with .gotoAndStop[20] but so far anything i tried has failed.
i can get the index from the Child by using
hexnumber = (e.target.parent.getChildIndex(e.target));
but im not sure how to acces that particular hex to change his frame.
im pretty sure there is some really obvious way to do this, but my knowledge of as3 is really limited so far, so, i could really use some help.
thank you in advance.