/ Published in: ActionScript
URL: http://proto.layer51.com/d.aspx?f=1524
// method // just use true or false to control the handCursor usage; the defalut is true. mc1.dragEasing(false); mc2.dragEasing();
Expand |
Embed | Plain Text
//-----------------------------------// // Drag with easign and bringToFront // //-----------------------------------// // MovieClip.prototype.dragEasing = function(handCursor) { // control hand cursor (handCursor == "") ? this.useHandCursor=true : this.useHandCursor=handCursor; this.xfinal = this._x; this.yfinal = this._y; // on press drag this.onPress = function() { //bring to front mx.behaviors.DepthControl.bringToFront(this); this.arrastrar = true; this.xd = this._x-_root._xmouse; this.yd = this._y-_root._ymouse; //on enterframe move the mc with easing this.onEnterFrame = function() { if (this.arrastrar == true) { this.x = _root._xmouse+this.xd; this.y = _root._ymouse+this.yd; } else { this.x = this.xfinal+this.xd; this.y = this.yfinal+this.yd; } this._x = this._x+(this.x-this._x)/3; this._y = this._y+(this.y-this._y)/3; // end of easing if (Math.abs((this.x-this._x)/3)<0.5 && this.arrastrar == false) { delete this.onEnterFrame; } }; }; // on release set the end point this.onRelease = this.onReleaseOutside=function () { this.arrastrar = false; this.xfinal = _root._xmouse; this.yfinal = _root._ymouse; }; };
You need to login to post a comment.
