# Create new instance of movieClip\_A to center of movieClip\_B

**URL:** https://forum.kirupa.com/t/create-new-instance-of-movieclip-a-to-center-of-movieclip-b/331721
**Category:** programming
**Created:** [October 5, 2013, 8:19pm UTC](https://forum.kirupa.com/t/create-new-instance-of-movieclip-a-to-center-of-movieclip-b/331721 "2013-10-05T20:19:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![adove](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@adove](https://forum.kirupa.com/u/adove)
#### Post date: [October 5, 2013, 8:19pm UTC](https://forum.kirupa.com/t/create-new-instance-of-movieclip-a-to-center-of-movieclip-b/331721/1 "2013-10-05T20:19:12Z")

</div>

I am creating a farm game and I am trying to drag an object (red spot) over the ground. When the object rolls over a soil square it highlights a different color. I am trying to drop the object onto the colored soil and have it plant some corn. My cornCrop movieClip is supposed to appear in the middle of the highlighted soil. I posted some code and a screenshot. In the code snippet i have some hard-coded x,y coordinates for the corn stalk to appear. How do I get the corn stalk to dynamically appear in the center of the highlighted soil movieClip? Plus, I can see that I should probably use some sort of array for the corn because I don’t know how many times a user will want to plant them. I am not sure how to do that either.

```auto

if (bucketCorn.hitTestObject(Grid.Cell_3_1))
			{
				var gridID = Grid.Cell_3_1;
				//addCrop();
				//myColorTransform.color = 0x00FF33;
				//Grid.Cell_3_1.transform.colorTransform = myColorTransform;
				trace("Yogi Bear!");
				var cropCorn1 = new CropCorn();
				
				cropCorn1.x = 50;
				cropCorn1.y = 400;

				addChild(cropCorn1);
			}
			
			if (bucketCorn.hitTestObject(Grid.Cell_3_2))
			{
				//addCrop();
				//myColorTransform.color = 0x00FF33;
				//Grid.Cell_3_2.transform.colorTransform = myColorTransform;
				var cropCorn3 = new CropCorn();
				
				Grid.Cell_3_2.addChild(cropCorn3);
				
			}

```

Thanks,  
Alex
