# hitTestObject in a for statement

**URL:** <https://forum.kirupa.com/t/hittestobject-in-a-for-statement/322271>\
**Category:** flash\
**Created:** [May 16, 2011, 5:52pm UTC](https://forum.kirupa.com/t/hittestobject-in-a-for-statement/322271 "2011-05-16T17:52:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tattered](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Tattered](https://forum.kirupa.com/u/Tattered)\
**Post date:** [May 16, 2011, 5:52pm UTC](https://forum.kirupa.com/t/hittestobject-in-a-for-statement/322271/1 "2011-05-16T17:52:19Z")

</div>

Ok I am building a DnD, I have a hitTest setup, and I know when it hits it. But I can’t get out of the for statement if I drop it on the second object. It says it hit it, and then anims back to org. place.

```auto

public function onStopDrag(evt:MouseEvent):void {
			stopDrag();
			//
			for(var i:int = 1; i < arrayhitArea.length; i++){
				//
			}
			//
			if(this.getChildByName(evt.target.name).hitTestObject(getChildByName(arrayhitArea*))){
					trace("hit");
					this.getChildByName(evt.target.name).x = getChildByName(arrayhitArea*).x;
					this.getChildByName(evt.target.name).y = getChildByName(arrayhitArea*).y;
					arrayDropArea* = evt.target.name;
					trace(arrayDropArea);
				}else{
					trace("miss");
					var ballXTween:Tween = new Tween(this.getChildByName(evt.target.name),"x",Regular.easeOut,this.getChildByName(evt.target.name).x,numDragX,0.5,true);
					var ballYTween:Tween = new Tween(this.getChildByName(evt.target.name),"y",Regular.easeOut,this.getChildByName(evt.target.name).y,numDragY,0.5,true);
				}
		}

```

What am I doing wrong?
