So I have a movieclip named world in the bottom left of the screen which is suppose to "spawn" all of the block movieclips to fill the screen. The block movieclip is called block and exists only in the library. worldWidth, blockSize, and worldHeight are just numbers.
Normally, in AS2 I could just do this:
for (var x = 1; x <= blockWidth; x++) {
for (var y = 1; y <= blockHeight; y++) {
temp = world.attachMovie("block","bX" + x + "Y" + y, world.getNextHighestDepth());
temp._x = x*blockSize-blockSize/2;
temp._y = -y*blockSize+blockSize/2;
}
}
and all would be perfect..
But I'm using adobe air for android and AS3 is forced. AS3 is missing the "attachMovie()" function. I've searched for solutions but they are too situation-specific for me to understand.
Any ideas?
UPDATE:
I've tried to start on this using the answer provided and here's what I have:
stop();
import flash.display.MovieClip;
var blockSize:Number = 32;
var worldWidth:Number = 800/blockSize;
var worldHeight:Number = 480/blockSize;
render();
function render(){
for (var x = 1; x<=worldWidth; x++) {
for (var y = 1; y<=worldHeight; y++) {
var Block = new block();
Block.name = "BX" + x + "Y" + y;
Block.x = x*blockSize-blockSize/2;
Block.y = -y*blockSize+blockSize/2;
Block.gotoAndStop(3);
world.addChild(Block);
}
}
}
Unfortunately, the screen flashes constantly. I have no clue why.
EDIT: Really silly mistake, I forgot to stop() the frames inside the block MovieClip.
Question answered, problem solved!