PDA

View Full Version : Simple actionscript



amp
August 28th, 2003, 08:21 PM
How do I center the blocks in my AS?

fscommand ( "allowscale", false );

myMap = [ [0,0,0],
[0,0,0],
[0,0,0] ];

tileW = 32;
tileH = 32;

function buildMap (map) {
var mapWidth = map[0].length;
var mapHeight = map.length;
for (var i = 0; i<mapHeight; ++i) {
for (var j = 0; j<mapWidth; ++j) {
this.attachMovie("tile", "t_"+i+"_"+j, ++d);
this["t_"+i+"_"+j]._x = (j*tileW);
this["t_"+i+"_"+j]._y = (i*tileH);
this["t_"+i+"_"+j].gotoAndStop(map[i][j]+1);
}
}
}

buildMap (myMap);

jingman
August 29th, 2003, 11:44 AM
Well, it's hard to know what you're telling me without some kind of explination, but if you have some tiles that you want centered, stick them in an empty movie clip and center the clip with Stage.width/2 and Stage.height/2.

amp
August 29th, 2003, 03:14 PM
o ya thx man

jingman
August 29th, 2003, 03:17 PM
Originally posted by amp
o ya thx man

np :thumb: