When I run this code it just adds one tile at 0,0. Any ideas?
public function tile(obj:Object,times:int = 5,X:Number = 0, Y:Number = 0,Z:Number = 0, TileSize:Number = 50) {
var a:int = 0;
var b:int = 0;
while(a < times) {
addChild(new obj);
obj.x=X+(TileSize*a);
obj.y=Y+(TileSize*b);
obj.z=Z;
tileIndex.push(obj);
if (a==(times-1)) {
b++;
if (b < times) {
a=-1;
}
}
a++;
}
}