AS2 - Trying to create a grid of boxes
This is my current code:
_root.createEmptyMovieClip("noteGrid", _root.getNextHighestDepth());
for(i = 1; i <= 14; i++){
currentBlock = _root.noteGrid.attachMovie("block", "block" + i, _root.noteGrid.getNex开发者_如何学PythontHighestDepth);
currentBlock._x = Math.floor(i / 7) * 25;
currentBlock._y = (i % 7) * 25;
}
I have a movieclip with linkage set to block. When I compile this, the block appears however they are all on top of each other. When I used trace commands to find currentBlock._x
, they are the correct values.
The problem lies with your setting of depths.
_root.noteGrid.getNextHighestDepth
You are trying to access a property of noteGrid
, if you trace it you will see it tells you it is a function, rather than calling a function. To call the function do
_root.noteGrid.getNextHighestDepth()
By the looks of things your code isn't quite what you want but that can't really be fixed without you giving more details about what you're trying to do. Assuming you're trying to make a 2x7 grid, then you'll want to change your for loop to
for(i = 0; i < 14; i++)
精彩评论