# HitTest through function

**URL:** <https://forum.kirupa.com/t/hittest-through-function/54650>\
**Category:** flash\
**Created:** [June 16, 2004, 1:50pm UTC](https://forum.kirupa.com/t/hittest-through-function/54650 "2004-06-16T13:50:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghjr](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@ghjr](https://forum.kirupa.com/u/ghjr)\
**Post date:** [June 16, 2004, 1:50pm UTC](https://forum.kirupa.com/t/hittest-through-function/54650/1 "2004-06-16T13:50:09Z")

</div>

I’m having troubles activating the **HitTest** , passing the objects name as a parameter through a global function. Let’s say there is the following function on the main timeline:

```auto

_global.fallIntoBasket = function (fallingObject) {

	if (_root[fallingObject].hitTest(_x, _root.basket_mc._y+(_root.basket_mc._height/2)-7, true)) {
  		trace ("teste");
		_root[fallingObject]._alpha=0;
	}

}

```

I then call this function passing the this.\_name of the object as a parameter in a **onClipEvent (EnterFrame)** on each of the falling Objects action box. The whole detection thing doesn’t work though… but if I place the hitTest code on each of the object, and change the **\_root[fallingObject]** to **this** it works.

Any ideas? Can I not pass hitTest through a function? Thanks!!

ghjr
