?? lyric.as
字號(hào):
?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("參數(shù)1:請(qǐng)寫入播放音樂(lè)的對(duì)象.") : null;
test_txt_Obj == null ? trace("參數(shù)2:請(qǐng)寫入顯示歌詞的對(duì)象.") : null;
str == null ? trace("參數(shù)3:請(qǐng)寫入動(dòng)態(tài)歌詞字符串.") : null;
addLines == null ? trace("參數(shù)4:請(qǐng)寫入顯示歌詞的條數(shù).") : null;
the__color == null ? (trace("參數(shù)5:可寫入歌詞高亮的顏色,默認(rèn)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);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -