/ Published in: ActionScript 3
This code will arrange any number of images (or display objects) in a grid, you can specify how many columns the grid contains.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// This code should be placed in a for loop of some sort // that iterates through each of your images or display objects. // if(iNum==0) { // place the first image at 0,0 currX = 0; currY = 0; } else if(iNum%2 == 0) { // Change "2" to however many columns this grid should have. // This runs anytime iNum is evenly divisible by 2 // Which sets currX to 0 and adds another row height to currY // Essentially starting a new row. currY += _imageHeight + _imageSpacing; currX = 0; } else { currX += _imageWidth + _imageSpacing; } images[i].x = currX; images[i].y = currY;
URL: http://www.cannedbanners.com