var movespeed = 8;//移动速度
//mc 移动的影片
//long 移动距离
//posx 原始x坐标
function leftbody(mc:MovieClip, long:Number, posx:Number) {
    var old = posx;
    this.onEnterFrame = function() {
        if ((mc._x-(old-long))>movespeed) {
            mc._x = mc._x-movespeed;
        } else if ((mc._x-(old-long))>0) {
            mc._x = mc._x-(mc._x-(old-long));
        } else {
            this.onEnterFrame = null;
            delete this.onEnterFrame;
        }
        //trace(mc._x);
    };
}
function rightbody(mc:MovieClip, long:Number, posx:Number) {
    var old = posx;
    this.onEnterFrame = function() {
        if (((old+long)-mc._x)>movespeed) {
            mc._x = mc._x+movespeed;
        } else if (((old+long)-mc._x)>0) {
            mc._x = mc._x+((old+long)-mc._x);
        } else {
            this.onEnterFrame = null;
            delete this.onEnterFrame;
        }
        //trace(mc._x);
    };
}

相关文章:

  • 2022-02-03
  • 2022-02-11
  • 2021-08-12
  • 2021-10-29
  • 2021-10-05
  • 2021-05-18
  • 2021-05-20
  • 2022-12-23
猜你喜欢
  • 2021-06-23
  • 2022-03-02
  • 2021-05-31
  • 2021-07-12
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
相关资源
相似解决方案