# Drag and throw w/ MULTIPLE movie clips? please help?

**URL:** <https://forum.kirupa.com/t/drag-and-throw-w-multiple-movie-clips-please-help/273204>\
**Category:** Uncategorized\
**Created:** [October 13, 2008, 12:57am UTC](https://forum.kirupa.com/t/drag-and-throw-w-multiple-movie-clips-please-help/273204 "2008-10-13T00:57:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chalemi](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@chalemi](https://forum.kirupa.com/u/chalemi)\
**Post date:** [October 13, 2008, 12:57am UTC](https://forum.kirupa.com/t/drag-and-throw-w-multiple-movie-clips-please-help/273204/1 "2008-10-13T00:57:01Z")

</div>

hello, i want to have the user be able to drag and throw movie clips around the stage, but with the code i have so far it only allows for one…how can i give the function to multiple clips without repeating the code a million times? here is what i have

```auto
bag.onPress = function(){
    anchorX = this._xmouse;
	anchorY = this._ymouse;
	this.onEnterFrame = function(){
        lastXMouse = _root._xmouse;
        lastYMouse = _root._ymouse;
		
        this._x = _root._xmouse - anchorX;
        this._y = _root._ymouse - anchorY;
    }
}

bag.onRelease = bag.onReleaseOutside = function(){
    xDirection = (_root._xmouse - lastXMouse);
    yDirection = (_root._yMouse - lastYMouse);
	this.onEnterFrame = function(){
		
	    
		// decay x
		if (Math.abs(xDirection) > 0.5){
			xDirection *= .9;
		} else { 
			xDirection = 0;
		}
		// decay y
		if (Math.abs(yDirection) > 0.5){
			yDirection *= .9;
		} else { 
			yDirection = 0;
		}
		
		
		if (xDirection == 0 && yDirection==0){
			this.onEnterFrame = null;
		}
		
		if (this._x < 0){
			xDirection *= -1;
			this._x = 0;
		}
		if (this._x + this._width > Stage.width){
			xDirection *= -1;
			this._x = Stage.width - this._width;
		}
		if (this._y < 0){
			yDirection *= -1;
			this._y = 0;
		}
	
		if (this._y + this._height > Stage.height){
			yDirection *= -1;
			this._y = Stage.height - this._height;
		}
		
		//Position
		this._x += xDirection;
		this._y += yDirection;
	
	}
}

```

THANKS!!!
