# Calling in functions

**URL:** <https://forum.kirupa.com/t/calling-in-functions/168930>\
**Category:** Uncategorized\
**Created:** [November 11, 2005, 9:40am UTC](https://forum.kirupa.com/t/calling-in-functions/168930 "2005-11-11T09:40:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drose429](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drose429/32/202_2.png) [@drose429](https://forum.kirupa.com/u/drose429)\
**Post date:** [November 11, 2005, 9:40am UTC](https://forum.kirupa.com/t/calling-in-functions/168930/1 "2005-11-11T09:40:42Z")

</div>

Hi  
In the following code I am trying to call the function pressMc when movieclip myMC\_mc is pressed and the apply the drag action to it. However the drag action is being applied to the whole of level0 and therefore all of the moviclips. I am not sure why. Am using the this key word as I would expect this to be identified as myMC\_mc when the myMC\_mc.onPress is evoked.  
I want to write this as a function because I want to apply this drag action to lots of different movieclips  
Anyone got and ideas  
much appreciated

function pressMc (){

delete this.oldX;  
delete this.oldY;  
this.onEnterFrame = function() {

```
	if (_xmouse&gt;this.oldX || _xmouse&lt;this.oldX) {
		this.startDrag(false, 25, this._y, 125, this._y);
		delete this.onEnterFrame;
	} else if (_ymouse&gt;this.oldY || _ymouse&lt;this.oldY) {
		this.startDrag(false, this._x, 25, this._x, 125);
		delete this.onEnterFrame;
	}
	this.oldX = _xmouse;
	this.oldY = _ymouse;
	trace (this);
};

```

};  
myMC\_mc.onPress = function() {

pressMc();  
};
