主题:  请教:怎样得到鼠标在一个按钮上的拖动距离??

yeilong

职务:普通成员
等级:1
金币:0.0
发贴:188
#12003/1/15 11:14:39
主场景按钮上加以下代码:
on (dragOut) {

x= _root._xmouse-_x;
y= _root._ymouse-_y;

args = x+"|"+y;
fscommand("drag", args);
}

好像不对!



s22

职务:版主
等级:4
金币:10.0
发贴:1634
#22003/1/15 12:28:42
Math.distance = function (x1, y1, x2, y2) {
    var deltaX = x2-x1;
    var deltaY = y2-y1;
    return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
}
my_btn.onDragOut=function(){
this._parent.onEnterFrame=function(){
trace("distance:"+Math.distance(this._x,this._y,_root._xmouse,_root._yMouse))
}
}
my_btn.onRelease=function(){
delete this._parent.onEnterFrame;
}



yeilong

职务:普通成员
等级:1
金币:0.0
发贴:188
#32003/1/15 13:02:15
thx~
其实我想X、Y都得到,通过拖动这个按钮拖动无边框窗口,现在它只往一个方向走,气死偶了



s22

职务:版主
等级:4
金币:10.0
发贴:1634
#42003/1/15 13:04:55
en~加个获取角度的就好了~



yeilong

职务:普通成员
等级:1
金币:0.0
发贴:188
#52003/1/15 13:21:36
问题是俺不会加,为什么 _root._xmouse-_x得不到负值??



s22

职务:版主
等级:4
金币:10.0
发贴:1634
#62003/1/15 13:53:47
鼠标在MC的右边就会得到负的value
在FLASH的SAMPLE文件中能找到判断角度的一个。