鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 网站制作教程 > flash > >

FlashAS关于定点移动的解决方案分析

来源:互联网 作者:佚名 时间:2016-03-14 10:14
var mouseListener:Object=new Object(); var totalLength:Number=0; var pileLength:Number=0; var speed:Number=5; //匀速运动,此是定值。 mouseListener.onMouseDown=function(){ _root.totalLength=obj._x-_root._xmouse; _root.onEnterFrame=function(

  var mouseListener:Object=new Object();
var totalLength:Number=0;
var pileLength:Number=0;
var speed:Number=5; //匀速运动,此是定值。
mouseListener.onMouseDown=function(){
       _root.totalLength=obj._x-_root._xmouse;
       _root.onEnterFrame=function(){
              if(_root.pileLength+_root.speed<=Math.abs(_root.totalLength)){
                     if(_root.totalLength<0){
                            obj._x+=_root.speed;
                     }else{
                            obj._x-=_root.speed;
                     }
                     _root.pileLength+=_root.speed;
              }else{
                     if(_root.totalLength<0){
                            obj._x+=Math.abs(_root.totalLength)-_root.pileLength;
                     }else{
                            obj._x-=Math.abs(_root.totalLength)-_root.pileLength;
                     }
                     _root.pileLength=0;
                     _root.totalLength=0;
                     delete _root.onEnterFrame;
              }
       }
}
Mouse.addListener(mouseListener);

  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);

  var mouseListener:Object = new Object();
var totalLength:Number = 0;
var speed:Number = 3;
var count:Number = 0;
var spare:Number = 0;
var position:Number = 0;
mouseListener.onMouseDown = function() {
       _root.totalLength = people._x-_root._xmouse;
       unt = Math.abs(Math.floor(_root.totalLength/_root.speed));
       _root.spare = _root.totalLength%_root.speed;
       _root.onEnterFrame = function() {
              if (unt != 0) {
                     //判断方向
                     if (_root.totalLength>0) {
                            obj._x += _root.speed;
                     } else {
                            obj._x -= _root.speed;
                     }
                     unt--;
              } else {
                     if(_root.totalLength<0){
                            obj._x -= _root.spare;
}else{
       obj._x+=_root.spare;
}
                     _root.spare = 0;
                     _root.totalLength = 0;
                     delete _root.onEnterFrame;
              }
       };
};
Mouse.addListener(mouseListener);

  

网友评论
<