# AS3 Adding child on collide with another object

**URL:** <https://forum.kirupa.com/t/as3-adding-child-on-collide-with-another-object/329676>\
**Category:** flash\
**Created:** [October 1, 2012, 8:32am UTC](https://forum.kirupa.com/t/as3-adding-child-on-collide-with-another-object/329676 "2012-10-01T08:32:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![teegiimonstuhh](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@teegiimonstuhh](https://forum.kirupa.com/u/teegiimonstuhh)\
**Post date:** [October 1, 2012, 8:32am UTC](https://forum.kirupa.com/t/as3-adding-child-on-collide-with-another-object/329676/1 "2012-10-01T08:32:02Z")

</div>

Hello,

I’m trying to add another instance of my GurlBall to the stage, whenever a gBall instance collides with a bBall instance. (Does that make sense?) I have a GurlBall, Ball, and a BallCollision actionscript file.

GurlBall.as:

```auto

private function hitTest():void {// for (var i:int = 0; i < Main.bFishList.length; i++)
		{
			if (this.hitTestObject(BallCollision.bFishList*))
			{
				trace("hitEnemy");
				speedX = -speedX;
				speedY = -speedY;
				addChild(this);
				
			}
		}

```

How would I reference the bBall instance in the BallCollision file, and how can I add a gBall instance when they collide?
