# Referring to Movieclip in Array Using Names

**URL:** <https://forum.kirupa.com/t/referring-to-movieclip-in-array-using-names/321784>\
**Category:** flash\
**Created:** [May 1, 2011, 1:53pm UTC](https://forum.kirupa.com/t/referring-to-movieclip-in-array-using-names/321784 "2011-05-01T13:53:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CCG1993](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@CCG1993](https://forum.kirupa.com/u/CCG1993)\
**Post date:** [May 1, 2011, 1:53pm UTC](https://forum.kirupa.com/t/referring-to-movieclip-in-array-using-names/321784/1 "2011-05-01T13:53:01Z")

</div>

I am writing a program where I have used multiple movieclips (boxes) that are put into a grid using a nested for loop.

Each movieclip is in an array and I want to give them names (box1, box2, e.t.c) but when I try to trace() them i get this in the output: “[object gridBox]”.

Here’s my code:

```auto
var gridBoxArray:Array = new Array()

var rows:int = 6
var columns:int = 6
for (var a = 0; a < rows; a++){
 for (var b = 0; b < columns; b++){
  var newGridBox:MovieClip = new gridBox()
  newGridBox.x = a * (newGridBox.width)
  newGridBox.y = b * (newGridBox.height)
  addChild(newGridBox)
  gridBoxArray.push(newGridBox)
  newGridBox.name = "box" + gridBoxArray.index
 }
}
trace(gridBoxArray[0])
 

```

Can anyone help?

Thanks,

ccg1993
