Posted By

Nikolai on 10/11/10


Tagged

as3 grid Modulo arrange


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Leang


modulo grid


 / Published in: ActionScript
 

arrange items in a grid pattern

  1. var boxNum:int = 15;
  2. var cols:int = 4;
  3.  
  4. for (var i:int = 0; i<boxNum; i++) {
  5.     var box:Box = new Box();
  6.     box.x = 50 + box.width * (i % cols);
  7.     box.y = 50 + box.height * int(i / cols);
  8.     addChild(box);
  9. }

Report this snippet  

You need to login to post a comment.