Senin, 10 Juni 2013

Grid Formation For Movieclip With Array In As2


To make the movieclip in grid formation we need the array() and modulo function. We use the array function to distribute movieclip in x coordinate, whereas modulo function to distribute movieclip in y coordinate. To make that formation,  first make a movielip named “mc”. In frame 1 write the following code:
//actionscript grid positioning
ordo = 6;
totalMC = ordo*ordo;
for (i=0; i<totalMC; i++) {
far = new Array(50, 100, 150, 200, 250, 300);
n = i%ordo;
mc.duplicateMovieClip("mc"+i, i);
pos = eval("mc"+i);
pos._x = far[n];
pos._y = 50*((i-n)/ordo);
trace(n);
}
mc._visible=false;

ordo = 6 is the total of movie clip in horizontal position. TotalMC will make the formation in square. You can costumized the formation with change the value of ordo and Array.

Tidak ada komentar:

Posting Komentar