+ -
当前位置:首页 → 问答吧 → 【求助】鼠标点击后移动到点击位置,如果自动怎么实现?

【求助】鼠标点击后移动到点击位置,如果自动怎么实现?

时间:2010-11-26

来源:互联网

实例mc中加入以下代码,实现点击后mc可以移动到鼠标点击的位置,但是过程鼠标不能松开,请教大家如果要松开的话代码应该怎么写?
复制内容到剪贴板
代码:
mc.onEnterFrame = function() {
    if (Key.isDown(1)) {
        var mcx = _root._xmouse;
        var mcy = _root._ymouse;
        var xspeed:Number = (_root._xmouse-this._x)/3;
        var yspeed:Number = (_root._ymouse-this._y)/3;
    }
    if (Math.abs(mcx-this._x) and Math.abs(mcy-this._y)) {
        this._x += xspeed;
        this._y += yspeed;
    }
};

作者: youxiaohanpian   发布时间: 2010-11-26

import gs.TweenLite;
mc.onPress=function(){
TweenLite.to(this,1,{_x:_xmosue,_y:_ymouse});
}

作者: flash023   发布时间: 2010-11-26

引用:
原帖由 flash023 于 2010-11-26 13:33 发表
import gs.TweenLite;
mc.onPress=function(){
TweenLite.to(this,1,{_x:_xmosue,_y:_ymouse});
}
还是不明白,能说的详细点吗?

作者: youxiaohanpian   发布时间: 2010-11-26