Posted By

andrewrench on 08/16/07


Tagged

actionscript easing drag


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

n00ge
andrewrench
arala22
imhugo


movieClip.DragWithEasign && bringToFront


 / 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();

  1. //-----------------------------------//
  2. // Drag with easign and bringToFront //
  3. //-----------------------------------//
  4. //
  5. MovieClip.prototype.dragEasing = function(handCursor) {
  6. // control hand cursor
  7. (handCursor == "") ? this.useHandCursor=true : this.useHandCursor=handCursor;
  8. this.xfinal = this._x;
  9. this.yfinal = this._y;
  10. // on press drag
  11. this.onPress = function() {
  12. //bring to front
  13. mx.behaviors.DepthControl.bringToFront(this);
  14. this.arrastrar = true;
  15. this.xd = this._x-_root._xmouse;
  16. this.yd = this._y-_root._ymouse;
  17. //on enterframe move the mc with easing
  18. this.onEnterFrame = function() {
  19. if (this.arrastrar == true) {
  20. this.x = _root._xmouse+this.xd;
  21. this.y = _root._ymouse+this.yd;
  22. } else {
  23. this.x = this.xfinal+this.xd;
  24. this.y = this.yfinal+this.yd;
  25. }
  26. this._x = this._x+(this.x-this._x)/3;
  27. this._y = this._y+(this.y-this._y)/3;
  28. // end of easing
  29. if (Math.abs((this.x-this._x)/3)<0.5 && this.arrastrar == false) {
  30. delete this.onEnterFrame;
  31. }
  32. };
  33. };
  34. // on release set the end point
  35. this.onRelease = this.onReleaseOutside=function () {
  36. this.arrastrar = false;
  37. this.xfinal = _root._xmouse;
  38. this.yfinal = _root._ymouse;
  39. };
  40. };

Report this snippet  

You need to login to post a comment.