作者:vim
来源:闪吧BBS
热度:
2007-10-29 15:56:51
与累积路径法相反,他是通过求出剩余的路径的长度,如果剩余路径长度为零就代表已经到达目的点。
让我们先看看源码吧:
| var mouseListener:Object=new Object(); var totalLength:Number=0; var speed:Number=5; //匀速运动,此是定值。 mouseListener.onMouseDown=function(){ _root.totalLength=obj._x-_root._xmouse; _root.onEnterFrame=function(){ if(_root.totalLength>=_root.speed){ if(_root.totalLength<0){ obj._x+=_root.speed; _root.totalLength+=_root.speed; }else{ obj._x-=_root.speed; _root.totalLength-=_root.speed; } }else{ If(_root.totalLength<0){ obj._x+=_root.totalLength; }else{ obj._x-=_root.totalLength; } _root.totalLength=0; delete _root.onEnterFrame; } } } Mouse.addListener(mouseListener); |
我来说两句:
推荐文章
相关文章