# Problems with attachMovie

**URL:** <https://forum.kirupa.com/t/problems-with-attachmovie/305512>\
**Category:** flash\
**Created:** [February 26, 2010, 10:50am UTC](https://forum.kirupa.com/t/problems-with-attachmovie/305512 "2010-02-26T10:50:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaewin](https://avatars.discourse-cdn.com/v4/letter/z/258eb7/32.png) [@zaewin](https://forum.kirupa.com/u/zaewin)\
**Post date:** [February 26, 2010, 10:50am UTC](https://forum.kirupa.com/t/problems-with-attachmovie/305512/1 "2010-02-26T10:50:51Z")

</div>

Hey, people!

I’ve got a small issue with attachMovie.

I’ve got an array with references to movie clips which I want to place at random locations on the scene.

Here is my function:

```auto

function randomize(target_array){
	top_y = 87;
	bottom_y = 296;
	
	left_x_range = 16;
	right_x_range = 220;
	
	left_x_range_second = 305;
	right_x_range_second = 535;
	
	for(i = 0; i < target_array.length; i++){
		mc = target_array*;
		trace(mc);
		
		mc_clothes_holder.attachMovie(""+mc+"", ""+mc+"", mc_clothes_holder.getNextHighestDepth());
		
		trace("++> "+mc_clothes_holder);
		
		currY = Math.floor(Math.random() * (1 + bottom_y - top_y)) + top_y;
		
		if(i%2 != 0){
			currX = Math.floor(Math.random() * (1 + right_x_range - left_x_range)) + left_x_range;
			mc_clothes_holder.mc._x = currX;
			mc_clothes_holder.mc._y = currY;
		}else{
			currX = Math.floor(Math.random() * (1 + right_x_range_second - left_x_range_second)) + left_x_range_second;
			mc_clothes_holder.mc._x = currX;
			mc_clothes_holder.mc._y = currY;
		}
	}
}

```

The thing here is that the trace of “mc” in the beginning returns the correct movie clip reference, but “mc\_clothes\_holder.mc” after the attachMovie returns “undefined”.

Does anyone have any idea why this doesn’t work? What have I done wrong?

Thanks!
