• 【设为首页】
  • 【收藏闪客居】
当前位置:主页>FLASH AS 编程>AS进阶篇>文章内容
  • Flash中限定自由区域的拖拽
  • 来源:flashxm.com 作者:xiangming 2006-07-22 【

场景中有一个被拖拽的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;


源文件下载
/upimg/soft/4/1_060723053228.fla



上一篇:updateAfterEvent实例解释   下一篇:用Flash影片剪辑复制做“鼠标跟随”特效
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)