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
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!!!