场景中有一个被拖拽的mc和一个自由区域的mc,分别用startDrag和hitTest。
先拖拽,再用鼠标对自由区域的mc进行true的hitTest,然后记录位置,最后写回。
具体代码如下:

function update() {
  if (area_mc.hitTest(_xmouse, _ymouse, true)) {
    temp_x = _xmouse;
    temp_y = _ymouse;
  } else {
    handle_mc._x = temp_x;
    handle_mc._y = temp_y;
  }
}
handle_mc.onPress = function() {
  drag = true;
  this.startDrag();
};
handle_mc.onRelease = handle_mc.onReleaseOutside = function () {
  drag = false;
  stopDrag();
  update();
};
onMouseMove = function () {
  if (drag) {
    update();
  }
};
var drag, temp_x, temp_y;


源文件下载

相关文章:

  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2021-05-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2021-08-21
相关资源
相似解决方案