# Any way to shorten this?

**URL:** https://forum.kirupa.com/t/any-way-to-shorten-this/200869
**Category:** flash
**Created:** [September 15, 2006, 10:30pm UTC](https://forum.kirupa.com/t/any-way-to-shorten-this/200869 "2006-09-15T22:30:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![REEF](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@REEF](https://forum.kirupa.com/u/REEF)
#### Post date: [September 15, 2006, 10:30pm UTC](https://forum.kirupa.com/t/any-way-to-shorten-this/200869/1 "2006-09-15T22:30:24Z")

</div>

```auto
row1 = 5;
totalpics = 10;
// makes containers for row 1
for (i = 1; i < row1; i++) {
	dupMovies(i);
}
// makes containers for row 2
for (j = row1; j < totalpics; j++) {
	dupMovies2(j);
}
// function for row 1 containers
function dupMovies(n) {
	oldn = n - 1;
	duplicateMovieClip(container0, "container" + n, n);
	_root['container' + n]._x = (_root['container' + oldn]._x) + boxPorps + 1;
	_root['container' + n]._y = container0._y;
	duplicateMovieClip("container" + n, "btn" + n, n + totalpics);
	_root["btn" + n]._alpha = 0;
	_root["btn" + n]._width = boxPorps;
	_root["btn" + n]._height = boxPorps;
	_root["btn" + n]._x = (_root['container' + n]._x);
	_root["btn" + n]._y = (_root['container' + n]._y);
}
// function for row 2 containers
function dupMovies2(z) {
	oldz = z - 1;
	duplicateMovieClip(container0, "container" + z, z);
	_root['container' + z]._x = (_root['container' + (oldz - row1)]._x) + boxPorps + 1;
	_root['container' + z]._y = container0._y + boxPorps + 1;
	duplicateMovieClip("container" + z, "btn" + z, z + totalpics);
	_root["btn" + z]._alpha = 0;
	_root["btn" + z]._width = boxPorps;
	_root["btn" + z]._height = boxPorps;
	_root["btn" + z]._x = (_root['container' + z]._x);
	_root["btn" + z]._y = (_root['container' + z]._y);
}

```

Note, the 3rd/4th line of each function is different. Any possible way to shorten this at all? Anyway to improve the code?
