# attachMovie() Method

**URL:** https://forum.kirupa.com/t/attachmovie-method/38380
**Category:** flash
**Created:** [December 22, 2003, 5:05am UTC](https://forum.kirupa.com/t/attachmovie-method/38380 "2003-12-22T05:05:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![riveroaks](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@riveroaks](https://forum.kirupa.com/u/riveroaks)
#### Post date: [December 22, 2003, 5:05am UTC](https://forum.kirupa.com/t/attachmovie-method/38380/1 "2003-12-22T05:05:58Z")

</div>

Im trying to use a loop to set up 4 rows of 10 “blocks” in flash…I have a movieclip with an idName of “Block”. My idea was to imbed the singular row of blocks loop within the loop of rows so that it generates the four rows quickly and all at once…I was trying to use the following code but it doesn’t work…it seems to show only the last block in the loop and i did some echo checking at the end and found that after the loop completes, there are no activated blocks…I found this by doing another loop and tracing all the blocks \_x properties which all returned undefined…even the last one which was still visible…:

```auto
/* Constants Section */
var NumBlocks = 10;
var NumRows = 4;
var StageWidth = Stage.width;
var StageHeight = Stage.height;
var BlockWidth = StageWidth/NumBlocks;
var BlockHeight = StageHeight/30;
var BlockName = " ";
/* End Constants Section */
for (RowCount = 1; RowCount <= NumRows; RowCount += 1) {
	for (BlockCount = 1; BlockCount <= NumBlocks; BlockCount += 1) {
		BlockName = "Block"+BlockCount+"Row"+RowCount;
		_root.attachMovie("Block",BlockName,(BlockCount*10));
		with (_root.BlockName) {
			_x = BlockWidth * BlockCount - BlockWidth;
			_y = BlockHeight * RowCount - BlockHeight;
			_width = BlockWidth;
			_height = BlockHeight;
		}
	}
}

```

so please tell me if there are any errors that really stick out at you…and if you do find an error please make sure that its one that might fix my problem because typically after people see one reply they do not read the post…which kinda screws me over…thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 22, 2003, 6:36am UTC](https://forum.kirupa.com/t/attachmovie-method/38380/2 "2003-12-22T06:36:55Z")

</div>

Welcome, riveroaks. =)

I think you’d only need to replace this line:

```auto
with (_root.BlockName) {

```

With this one:

```auto
with (_root[BlockName]) {

```

See [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082) for more info. 😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 22, 2003, 4:24pm UTC](https://forum.kirupa.com/t/attachmovie-method/38380/3 "2003-12-22T16:24:17Z")

</div>

wow…im surprised that worked…why did it work? I read the thread in that link but I still don’t understand…aren’t those brackets used for arrays when referencing names? I know that im basically creating my own array but i never defined my rows of blocks as arrays so why would I use the brackets? This isn’t a very crucial issue but if anyone could take a sec to explain it, id appreciate it.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [December 22, 2003, 4:33pm UTC](https://forum.kirupa.com/t/attachmovie-method/38380/4 "2003-12-22T16:33:57Z")

</div>

You’re welcome. 😛

And well, you should read the thread again if you didn’t understand it… I honestly cannot explain it better than that. Sorry. :-\

…Good luck! 😉
