flash lite as2.0水平移动方法
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);
};
}
//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);
};
}