View Single Post
Old 11-17-2012, 12:02 PM   PM User | #5
Goos
New Coder

 
Join Date: Apr 2011
Posts: 45
Thanks: 0
Thanked 11 Times in 11 Posts
Goos is an unknown quantity at this point
You're running your loop one time too many.
Code:
var arr = ['A','B','C'];
arr.length; //3
for(var i=0; i < arr.length; i++){} // arr[0]: A, arr[1]: B, arr[2]: C
Code:
 this.popMap = function()
                           {
                               tileset.makeTiles();
                               this.tileset = tileset.tile; 
                              
                              
                               var yCount = 0;
                               var xCount = 0;
                               var swtch = 0;
                               for(i = 0; i < (this.mapData.length); i++)
                                   {
                                       var data = mapData[i]
                                       switch (swtch)
                                       {
                                           case 0:
                                               this.row[yCount] = document.createElement('tr');
                                               this.map.appendChild(this.row[yCount]);
                                               swtch = 1;
                                               break;
                                           case 1:
                                               break;
                                           case 2:
                                               xCount = 0;
                                               yCount++;
                                               swtch = 1;
                                               this.row[yCount] = document.createElement('tr'); 
                                               this.map.appendChild(this.row[yCount]);
                                               break;
                                           }
                                       xCount++;
                                            if (xCount >= numCellsX)
                                           {
                                                swtch = 2;
                                           } 
                                       
                                       
                                       this.row[yCount].appendChild(this.tileset[data]);
                                       alert(this.row[yCount].tileset[i]); 
                                       //xCount++;
                                   }
                                   alert('done!!!');
                           }
Goos is offline   Reply With Quote