Hello all.
I'm a bit of a weekend warrior when it comes to flash, so bear with me.
Basically, I'm writing an application to be used for Dungeons and Dragons. The idea is to replace traditional battle-mats and markers with a laptop and projector. Now, to the problem.
I'm using Filippo Lughi's method of slicing up a tileset image (http://www.flepstudio.org/forum/tuto...ipt-3-0-a.html -- great tutorial), placing individual tiles into an array, reading an array from a text file, then placing tiles from the tiles array on the stage corresponding the text file. Here's the troublesome bit of code.
Code:
var tilenum:int=0;
for (var k=0;k<currentMapArray.length;k++) {
for (var l=0;l<currentMapArray[k].length;l++) {
tilenum=currentMapArray[k][l];
var tileToAdd:MovieClip = new MovieClip();
tileToAdd = clips_array[tilenum];
addChild(tileToAdd);
tileToAdd.name = "tile-"+l+"-"+k;
tileToAdd.width=gridSize;
tileToAdd.height=gridSize;
tileToAdd.x = gridSize*l;
tileToAdd.y = gridSize*k;
trace(tileToAdd.name);
}
}
When the code is run, all of the tile names are traced, but only two tiles end up on the stage. The two that make it onto the stage are the last instances of each type of tile (image attached). It seems like each run through the loop replaces the previously placed tile if it's the same type. Does anyone have an idea why this is happening? No errors are thrown during compiling. When I check Objects, there are only two tile clips listed-- the two on the stage.
Any insight would be greatly appreciated. I can post the rest of the code if necessary. Thanks!
-Hero
The zeros correspond to a particular tile, as do the ones. clips_array is the array that stores the individual sliced tiles from the original tileset image.
Yeah, I've traced tilenum. It outputs the correct value for each point on the grid. currentMapArray is a nested array.
Before I implemented the actual bitmap tiles, I was using dummy movieclips that were just black and white squares. Black was 0, white was 1. Everything worked fine there.
The distribution of the clips over the squares is ok. That is not the problem. You need to check if the MovieClips have images. It seems that is the problem.
- The right of the People to create Flash movies shall not be infringed. -