您的位置:首页 > 其它

Flash中限定自由区域的拖拽

2006-07-31 17:17 211 查看
场景中有一个被拖拽的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;

源文件下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: