I’m trying to understand a few lines of this piece of code:
fscommand("allowscale", "false");
var depth:Number = 0;
spacing = 20;
for (x=0; x<5; x++) {
for (y=0; y<5; y++) {
tile = gridMC.attachMovie("tile", "tile"+depth, depth++);
tile._x = spacing*(x+y);
tile._y = spacing/2*(x-y);
tile.x = x;
tile.y = y;
tile.onRelease = function() {
trace("x:"+this.x+",y:"+this.y);
};
}
}
I don’t understand this:
var depth:Number = 0;
I understand that “var” is used to define the variable “depth”, but I don’t understand “:Number=0;”
Next:
tile = gridMC.attachMovie("tile", "tile"+depth, depth++);
I looked up “attachMovie” in the AS dictionary, but it didn’t clarify enough for me. attachMovie will attach the library item with linkage ID “tile” to the movieclip on the stage called “gridMC”. Then comes the part I don’t understand:
"tile"+depth, depth++
Can someone clarify the code above!
Cheers