分享
 
 
 

Flash版歌词秀

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

说明:这个歌词秀既可演示字幕,又可编辑歌词

当左上角显示为演示状态时,点击“播放”即可演示字幕

当显示为编辑状态时,点击“记时”既可为歌词添加时间标签

时间标签中包含每个句子的起始时间和结束时间,均用60进制表示,

最末位的单位是60分之一秒

--------------------------------------------

System.useCodepage = true;

//加载外部文本文件(文件路径,目标地址[,变量名称[,加载完毕后执行的函数]])

function loadTXT(url:String, temp:Object, func:Function) {

var depth = this.getNextHighestDepth();

var mc = this.createEmptyMovieClip("MC"+depth, depth);

var tt = setInterval(test, 50);

loadVariables(url, mc);

function test() {

if (mc.txtend != undefined) {

temp.data = mc.jhdata;

if (func != null) {

func();

}

removeMovieClip(mc);

clearInterval(tt);

}

}

}

//将10进制数N转换成d进制数(以0-9,A-Z,a-z字符表示),d为2-62

function jh_10toD(N:Number, d:Number) {

N = Math.floor(N);

d = d<2 ? 2 : d>62 ? 62 : d;

var s, e = "";

while (N>0) {

s = N%d;

if (s>35) {

//36至62的数用a-z字符表示(s-36+97)

s = String.fromCharCode(s+61);

} else if (s>9) {

//10至35的数用A-Z字符表示(s-10+65)

s = String.fromCharCode(s+55);

}

e = s+e;

N = Math.floor(N/d);

}

e = e != "" ? e : "0";

return e;

}

//将d进制数str转换为10进制

function jh_Dto10(str:String, d:Number) {

var code = 0, num = 0;

for (var i = 0; i<str.length; i++) {

code = str.charCodeAt(i);

if (code>96) {

code -= 61;

} else if (code>64) {

code -= 55;

} else {

code -= 48;

}

num += code*Math.pow(d, str.length-1-i);

}

return num;

}

//建立文本按钮(按钮字符,函数名,坐标,mc)

function get_button(BTtext:String, func:String, x:Number, y:Number, mc:MovieClip) {

mc = mc != null ? mc : this;

var depth = mc.getNextHighestDepth();

mc.createTextField("BT"+depth, depth, x, y, 15*BTtext.length, 20);

with (eval("BT"+depth)) {

selectable = false;

html = true;

htmlText = "<A HREF=\"asfunction:"+func+"\"><font color='#cc3300'>"+BTtext+"</A>";

}

}

//歌词处理:提取出每行的时间(换算为毫秒数)和歌词,存入数组(演示字幕用)

//如果没有时间信息,按同样格式转换,stime和etime置为""

function toarray(geci) {

geci = geci.split("\r\n");

for (var i in geci) {

var temp = geci[i];

var index1 = temp.indexOf(",");

var index2 = temp.indexOf("]");

geci[i] = {};

if (index2 == -1) {

if (temp == "" || temp == " ") {

geci.splice(i, 1);

} else {

geci[i].stime = "";

geci[i].etime = "";

geci[i].txt = temp;

}

} else {

geci[i].stime = 100/6*jh_Dto10(temp.slice(1, index1), 60);

geci[i].etime = 100/6*jh_Dto10(temp.slice(index1+1, index2), 60);

geci[i].txt = temp.slice(index2+1);

}

}

return geci;

}

//记录时间(编辑歌词用),geci为Object数组,每个元素包括(stime,etime,txt)

function get_time() {

if (loading.text == "编辑状态") {

var time = myMU.position;

//将1000分之一秒换算为60分之一秒,并转换为60进制数

time = jh_10toD(time/100*6, 60);

var i = Math.floor(counter/2);

if (i<geci0.length) {

if (counter%2 == 0) {

geci0[i].stime = "["+time+",";

} else {

geci0[i].etime = time+"]";

}

var newhtml = "<P align='center'>";

var sline = Math.max(i-2, 0);

var eline = Math.max(Math.min(i+4, geci0.length), 6);

var tempstr;

for (var j = sline; j<eline; j++) {

tempstr = geci0[j].stime+geci0[j].etime+geci0[j].txt;

if (j == i) {

newhtml += "<FONT color='#cc6600'><b>"+tempstr+"</b></FONT><BR>";

} else {

newhtml += tempstr+"<BR>";

}

}

in_out.htmlText = newhtml.slice(0, newhtml.length-4)+"</P>";

counter++;

}

}

}

//字幕演示

function mvtext(music:Sound, geci:Array) {

var tt2 = setInterval(test, 100);

var counter2 = 0;

function test() {

if (loading.text == "演示状态") {

if (music.position-geci[counter2].stime>0) {

while (music.position-geci[counter2].stime>0) {

counter2++;

}

counter2--;

var newhtml = "<P align='center'>";

var sline = Math.max(counter2-2, 0);

var eline = Math.max(Math.min(counter2+4, geci.length), 6);

for (var i = sline; i<eline; i++) {

if (i == counter2) {

newhtml += "<FONT color='#cc6600'><b>"+geci[i].txt+"</b></FONT><BR>";

} else {

newhtml += geci[i].txt+"<BR>";

}

}

in_out.htmlText = newhtml.slice(0, newhtml.length-4)+"</P>";

counter2++;

if (counter2>=geci.length) {

trace("kkkk");

clearInterval(tt2);

}

}

}

}

}

//

//建立状态显示框

this.createTextField("loading", this.getNextHighestDepth(), 13, 10, 100, 20);

loading.textColor = 0x339900;

loading.selectable = false;

//建立歌词显示框

this.createTextField("in_out", this.getNextHighestDepth(), 10, 10, 280, 100);

in_out.border = true;

in_out.multiline = true;

in_out.html = true;

in_out.htmlText = "";

//全局变量:

var geci0 = {};

var geci;

var counter = 0;

var stime = 0;

var myMU = new Sound(this);

//获取自身文件所在地址,加载同目录下同名txt文件,以获取mp3和txt的信息

var filepath = this._url.substr(0, this._url.length-3)+"txt";

var myurl = {};

loadTXT(filepath, myurl, loadMp3AndTxt);

delete filepath;

//获得mp3和txt的url信息后执行:

function loadMp3AndTxt() {

myurl = myurl.data.split("\r\n");

loadTXT(myurl[0], geci0, begin);

myMU.loadSound(myurl[1], false);

var myintervalID = setInterval(loadingtxt, 100);

function loadingtxt() {

var kk = Math.round(100*myMU.getBytesLoaded()/myMU.getBytesTotal());

if (kk == 100) {

go();

clearInterval(myintervalID);

}else{

loading.text = "加载中"+kk+"%";

}

}

delete myurl;

}

//获得歌词文本后执行:

function begin() {

geci = toarray(geci0.data);

geci0 = new Array();

for(var i=0;i<geci.length;i++){

geci0[i]={};

geci0[i].txt=geci[i].txt;

geci0[i].stime="";

geci0[i].etime="";

}

var newhtml = "<P align='center'>";

for (var i = 0; i<6; i++) {

newhtml += geci[i].txt+"<BR>";

}

in_out.htmlText =newhtml.slice(0,newhtml.length-4)+ "</P>";

}

myMU.onLoad = go;

//音乐加载完毕后执行:

function go() {

loading.text = "演示状态";

get_button("[演示]", "_show", 80, 110);

get_button("[编辑]", "_edit", 120, 110);

get_button("[播放]", "_play", 160, 110);

get_button("[暂停]", "_stop", 200, 110);

get_button("[记时] ", "get_time", 240, 110);

}

function _edit() {

loading.text = "编辑状态";

}

function _show() {

loading.text = "演示状态";

}

function _stop() {

stime = myMU.position/1000;

myMU.stop();

}

function _play() {

myMU.stop();

myMU.start(stime);

mvtext(myMU, geci);

}

myMU.onSoundComplete = _play;

this.onMouseUp = function() {

if (eval(Selection.getFocus()) == in_out && loading.text == "编辑状态") {

var temp = "<P align='center'>";

for (var i = 0; i<geci0.length; i++) {

temp += geci0[i].stime+geci0[i].etime+geci0[i].txt+"<BR>";

}

in_out.htmlText = temp+"</P>";

Selection.setSelection(0, in_out.length);

}

};

new _jh7086(100, null, 15, 112);

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有