效果描述:在动画运行框里面输入一串文本,然后点提交按钮,你就看到文本移动效果了!
代码如下:
本文作者:stop();
mc.setMask(mask_mc);
var v:Number = 5;//移动速度
var i:Number = 0;
var num:Number;
_btn.onPress = function() {
mc.t_txt.text = input_txt.text;
runMove();
};
_btn.onRelease = function() {
input_txt.text = "";
};
function runMove() {
onEnterFrame = function(){
if (mc._x>212) {
mc._x -= v;
}else{
delete onEnterFrame;
num=setInterval(funstop,1000);
};
updateAfterEvent();
};
};
function funstop() {
i++;
if (i>=4) {//中间停留
时间 clearInterval(num);
run_left();
}
}
function run_left() {
onEnterFrame = function () {
mc._x -= v;
if (mc._x<=94) {
delete onEnterFrame;
mc._x = 319;
}
updateAfterEvent();
};
}