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

实例mc中加入以下代码,实现点击后mc可以移动到鼠标点击的位置,但是过程鼠标不能松开,请教大家如果要松开的话代码应该怎么写?[ol][*]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;[*]? ? ? ? }[*]};[/ol][]

在图层上方再加一个大的透明的mc命名为a1大小将整个舞台覆盖。代码如下:[ol][*]a1.onRelease = function() {[*]? ? ? ? var mcx = _root._xmouse;//定义x坐标值为鼠标点击的x坐标[*]? ? ? ? var mcy = _root._ymouse;//定义y坐标值为鼠标点击的y坐标[*]? ? ? ? mc.onEnterFrame = function() {//获取影片剪辑的属性值的语句、以影片剪辑的帧频连续触发该动作[*]? ? ? ? ? ? ? ? mc._x += (mcx-mc._x)/10[*]? ? ? ? ? ? ? ? mc._y += (mcy-mc._y)/10[*]? ? ? ? ? ? ? ? if (mc._xmcx-1 && mc._y>mcy-1 && mc._y
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-11-14
import gs.TweenLite;mc.onPress=function(){TweenLite.to(this,1,{_x:_xmosue,_y:_ymouse});}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网