📄 lyric.as
字号:
class Lyric {
public var songId:Number;
function Lyric() {
}
public function read(song_Obj:Object, test_txt_Obj:Object, str:String, addLines:Number, the__color:String, speed:Number):Void {
clearInterval(songId);
song_Obj == null ? trace("参数1:请写入播放音乐的对象.") : null;
test_txt_Obj == null ? trace("参数2:请写入显示歌词的对象.") : null;
str == null ? trace("参数3:请写入动态歌词字符串.") : null;
addLines == null ? trace("参数4:请写入显示歌词的条数.") : null;
the__color == null ? (trace("参数5:可写入歌词高亮的颜色,默认0xFF0000."), the__color="#ff0000") : null;
speed == null ? speed=100 : null;
addLines--;
var contLines = int(addLines/2);
test_txt_Obj.html = true;
test_txt_Obj.htmlText = "";
var lrc:Array = new Array();
var templine = str.split("\n");
var templine_max = templine.length;
for (var i = 0; i<templine_max; i++) {
var thisIndex = 0;
var max = Pop.popTotal(templine[i], "]");
for (var j = 0; j<max; j++) {
var test = templine[i].slice(templine[i].lastIndexOf("]")+1, -1);
thisIndex = templine[i].indexOf("[", thisIndex);
var timer = Pop.popString(templine[i], "[", "]", thisIndex);
if (timer.charAt(2) == ":" && !isNaN(Number(timer.slice(3)))) {
var timers = (Number(timer.substring(0, 2))*60+Number(timer.slice(3)))*1000;
lrc.push({timer:timers, lyric:test});
}
thisIndex++;
}
}
var Maxlist = lrc.length;
lrc.sortOn("timer", Array.NUMERIC);
songId = setInterval(function () {
var thetime = song_Obj.position;
for (var i = 0; i<Maxlist; i++) {
if (Number(lrc[i].timer)<=thetime && Number(lrc[i+1].timer)>thetime) {
var test = "";
var Stimer = Number(lrc[i].timer);
var thelist_max = addLines-contLines+i;
for (var j = i-contLines; j<=thelist_max; j++) {
j == i ? test += "<b><font color='"+the__color+"'>"+lrc[j].lyric+"</font></b>\n" : (lrc[j].lyric != undefined ? test += lrc[j].lyric+"\n" : test += " \n");
}
test_txt_Obj.htmlText = test;
}
}
}, speed);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -