[原创]彻底分离按下(onRelease)和拖拽(startDrag)事件

      Flash及RIA 2007-4-23 12:58

代码如下:

var blnDrag:Boolean = false;
mc.onPress = function() {
 blnDrag = false;
 mc.onMouseMove = function() {
  if (!blnDrag) {
   trace("2 拖拽事件");
   this.startDrag();
   blnDrag = true;
  }
 };
};
mc.onRelease = function() {
 if (blnDrag) {
  trace("3 拖拽释放事件");
  this.stopDrag();
 } else {
  trace("1 按下事件");
  this.stopDrag();
  blnDrag = true;
 }
};

//增加了拷贝的方法
var __mcD:MovieClip;
var blnDrag:Boolean = false;
mc.onPress = function() {
 blnDrag = false;
 mc.onMouseMove = function() {
  if (!blnDrag) {
   __mcD = mc.duplicateMovieClip("mcD", _root.getNextHighestDepth());
   mcD._alpha = 50;
   mcD.startDrag();
   trace("2 (副本)拖拽事件");
   blnDrag = true;
  }
  mcD.onMouseUp = function() {
   delete onMouseMove;
   trace("3 (副本)拖拽释放事件");
   mcD.stopDrag();
   mc._x = mcD._x;
   mc._y = mcD._y;
   mcD.removeMovieClip();
  };
 };
};
mc.onRelease = function() {
 if (blnDrag) {
 } else {
  trace("1 (原件)按下事件");
  blnDrag = true;
 }
};


标签集:TAGS:分离 onRelease startDrag
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}