艺虎动画 > 简单的WINAMP文字滚动效果

简单的WINAMP文字滚动效果

翼虎动漫   2010-7-9

 

 

 

////创建一个文本框:

my_txt
this.createTextField("my_txt", 1, 100, 100, 248.1, 20);
my_txt.border = true;
my_txt.selectable = false;
my_txt.background = true;
my_txt.text = "";
//////////////////////////////////////////
//exam是示例字符串
exam = "12345.mp3";
//inc是计数器
inc = 0;
//显示四段,好使文字的前后连接起来,不会间断
str = exam+" "+exam+" "+exam+" "+exam+" ";
//把str打散
split_str = str.split("");
n = split_str.length;
this.onEnterFrame = function() {
inc++;
//每过八帧就显示一次。也就是移动一次
if (inc%8 == 0) {
//显示
showstr(split_str);
//交换
swap(split_str);
}
};
function showstr(tempstr) {
my_txt.text = "";
//这个是将所有的字符都显示一次
for (i=0; i<n; i++) {
my_txt.text += tempstr[i];
}
}
function swap(tempstr) {
//保存第一个字符
temp = tempstr[0];
//将字符后移一位
for (i=0; i<n-1; i++) {
tempstr[i] = tempstr[i+1];
}
tempstr[n-1] = temp;
}