# Grid of movieclips

**URL:** https://forum.kirupa.com/t/grid-of-movieclips/316287
**Category:** Uncategorized
**Created:** [November 17, 2010, 7:32pm UTC](https://forum.kirupa.com/t/grid-of-movieclips/316287 "2010-11-17T19:32:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![chilldog](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@chilldog](https://forum.kirupa.com/u/chilldog)
#### Post date: [November 17, 2010, 7:32pm UTC](https://forum.kirupa.com/t/grid-of-movieclips/316287/1 "2010-11-17T19:32:31Z")

</div>

I know I’m probably getting on your nerves with my frequent postings every time something goes wrong in my code, but I can’t figure out how to create a grid of movieclips, mainly positioning them according to x and y values. I’ve been trying hard all night to get this going, and I’m stumped. I’ve tried these sites -

[http://www.bigresource.com/FLASH-Creating-a-grid-with-Movie-Clips-FvEjRZaMHH.html](http://www.bigresource.com/FLASH-Creating-a-grid-with-Movie-Clips-FvEjRZaMHH.html)

> **[Creating a grid of movieclips and adjusting the grid based on stage width and...](https://www.kirupa.com/forum/showthread.php?282689-Creating-a-grid-of-movieclips-and-adjusting-the-grid-based-on-stage-width-and-height&s=35432cfd783012126ef477692c5dab36)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

(not quite what I have in mind, but…)

[http://www.flashvalley.com/fv\_tutorials/creating\_a\_grid\_dynamically/](http://www.flashvalley.com/fv_tutorials/creating_a_grid_dynamically/)

[http://board.flashkit.com/board/showthread.php?t=656202](http://board.flashkit.com/board/showthread.php?t=656202)

It’s all written in ActionScript 2.0…

Here is my code:

```auto
var cellX:Array = new Array();
var cellY:Array = new Array();
var previousX:int = 0;
var previousY:int = 0;

var columns:Array = new Array(10);
for (var i:Number=0; i<columns.length; i++)
{
	var row:Array = new Array(81);
	columns* = row;
	for (var k:Number=0; k<row.length; k++)
	{
		var gc = new GridCell();
		addChild(gc);
		row[k] = gc;
	}
}

setUpGrid();

function setUpGrid():void {
	columns[0][0].y = 90;
	previousY = columns[0][0].height + columns[0][0].y;
	columns[0][0].x = 150;
	previousX = columns[0][0].width + columns[0][0].x;
	for (var j:Number = 0; j < columns.length; j++) {
		for (var k:Number = 1; k < row.length; k++) {
			columns[j][k].y = previousY;
			previousY = columns[j][k].y + columns[j][k].height;
			columns[j][k].x = previousX;
			previousX = columns[j][k].x + columns[j][k].width;
		}
	}
}

```

All I get is a stair-stepping grid. What am I doing wrong? It would be helpful if you gave me a hint and maybe I’ll take it from there, but I’m not looking for an easy fix to this problem. I’d still like to tackle it myself because the project I’m working on will require a lot of heavy thinking…Or heavy drinking? Hmmmm. I love programming, and if I can’t get this - then I’m screwed. Bonus question: When you started programming, did you ever feel like you would never get the solution to your problems? Sometimes I feel that I’m not cut out for it and that every programmer started out an ace.
