注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

音画试听乐园

我的空间我做主 音乐无极限

 
 
 

日志

 
 
关于我

哥的世界不需要太多人懂。带上耳机.用音樂和麦克风驱赶悲傷,一声长叹何为缘?劳燕分飞两重天。泪眼作别转身去,柔情昨夜已成眠。尘世间的尘缘、以不再为红颜 无痕影音群号87433011 欢迎喜欢唱歌跳舞的你加入

网易考拉推荐

【转载】用FLASH 1祯做出卡拉OK动感歌词  

2016-08-08 19:25:59|  分类: FLASH教程 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
1、用flashcs3以上版本新建一个空白flash【大小任意,以下我的是910*150,主要是用于插入在其他音画或图上】,在第一祯插入以下代码
/*****************第一部分:系统参数设置、显示尺寸及模式、右键菜单功能****************/
System.useCodepage = false;
Stage.scaleMode = "NoScale";
Stage.align = "LT";
var stageResizeListener:Object = new Object();
stageResizeListener.onResize = fitmodels;
function fitmodels() {
lrcBar._x = Stage.width/2-350;
lrcBar._y = Stage.height-100;
mp3Cap._x = Stage.width-mp3Cap._width;
mp3Cap._y = Stage.height-35;
if (mp3Img._width) {
mp3Img._height = Stage.height-100;
mp3Img._xscale = mp3Img._yscale;
mp3Img._x = (Stage.width-mp3Img._width)/2;
}
}
Stage.addListener(stageResizeListener);
function switchDisplayMode() {
Stage["displayState"] == "normal" ? Stage["displayState"]="fullScreen" : Stage["displayState"]="normal";
}
function authorHomePage() {
System.setClipboard("");
getURL("/", "_blank");
}
function authorQQTalk() {
System.setClipboard("");
getURL("", "_blank");
}
var rightMenu:ContextMenu = new ContextMenu();
rightMenu.hideBuiltInItems();
rightMenu.customItems.push(new ContextMenuItem("□ 全屏显示/返回窗口", switchDisplayMode, true, true, true));
rightMenu.customItems.push(new ContextMenuItem("○ 签名", authorQQTalk, true, true, true));
rightMenu.customItems.push(new ContextMenuItem("⊙ XML-LRC单行卡拉OK风格歌词同步MP3列表播放器(一曲一图+全屏自适应)", authorHomePage, true, true, true));
this.menu = rightMenu;
/*****************第二部分:解析LRC文件的功能****************/
var lrcItem:Array;
var divsign:String = "|||";
function parseLRC(lrcStr) {
lrcItem = [];
var lrcLine:Array = lrcStr.split("\n");
for (var k:Number = 0; k<lrcLine.length; k++) {
for (var j:Number = 0; j<1000; j++) {
var subpos:Number = lrcLine[k].indexOf("]");
if (subpos<0) {
break;
} else {
var curTimeTag:String = lrcLine[k].slice(1, subpos);
curTimeTag.length == 5 ? curTimeTag += ".00" : null;
lrcItem[lrcItem.length] = curTimeTag+divsign+lrcLine[k].slice(lrcLine[k].lastIndexOf("]")+1);
lrcItem[lrcItem.length-1] = lrcItem[lrcItem.length-1].split("\r").join("").split("\n").join("");
lrcLine[k] = lrcLine[k].slice(subpos+1);
}
}
}
lrcItem.sort();
}
/*****************第三部分:显示LRC歌词的功能****************/
import flash.filters.BevelFilter;
var lrcBarBevelFilter:BevelFilter = new BevelFilter(1);
import flash.filters.DropShadowFilter;
var lrcBarDropShadowFilter:DropShadowFilter = new DropShadowFilter(1);
lrcBarDropShadowFilter.blurX = lrcBarDropShadowFilter.blurY=3;
var lrcTextFomart:TextFormat = new TextFormat();
lrcTextFomart.size = 28;
lrcTextFomart.bold = true;
//lrcTextFomart.font = "楷体_GB2312";
var curLrcId:Number;
var lrcHander:Number;
function getTimeMS(timeStr:String):Number {
return (Number(timeStr.split(":")[0])*60+Number(timeStr.split(":")[1])+Number(timeStr.split(".")[1])/10)*1000;
}
function getTimeStr(theTime:Number):String {
var sec = Math.floor(theTime/1000)%60;
sec<10 ? sec="0"+sec : null;
var min = Math.floor(Math.floor(theTime/1000)/60);
min<10 ? min="0"+min : null;
return min+":"+sec;
}
var secondPos:String;
var klokStepLong:Number;
var lrcMotionMode:Boolean = true;
var lrcBarFilterMode:Boolean = true;
function updateLrcBar() {
var curTime:Number = mp3Sound.position+300;
var mp3Time:String = getTimeStr(curTime);
if (secondPos != mp3Time) {
secondPos = mp3Time;
mp3Cap.htmlText = "<b><font color='#ff0000'>"+mp3Time+" / "+getTimeStr(mp3Sound.duration/(mp3Sound.getBytesLoaded()/mp3Sound.getBytesTotal()))+"</font></b> "+mp3CtrlHtml;
}
mp3Time += "."+String(curTime).slice(String(curTime).length-3, String(curTime).length-2);
//for (var i:Number = curLrcId+1; i<curLrcId+5; i++) {
for (var i:Number = curLrcId+1; i<lrcItem.length; i++) {
if (lrcItem[i].slice(0, 7) == mp3Time) {
curLrcId = i;
break;
}
}
if (lrcBar.lrcBase.lrcText.text != lrcItem[curLrcId].split(divsign)[1] && lrcBar._alpha>0) {
lrcBar._alpha -= 10;
lrcMotionMode == true ? lrcBar.lrcBase._x=lrcBar.lrcOver._x=Math.ceil((100-lrcBar._alpha)/10)/10*lrcBar.lrcBase.lrcText._width*1.5 : null;
} else if (lrcBar.lrcBase.lrcText.text == lrcItem[curLrcId].split(divsign)[1] && lrcBar._alpha<100) {
lrcBar._alpha += 10;
lrcMotionMode == true ? lrcBar.lrcBase._x=lrcBar.lrcOver._x=-Math.ceil((100-lrcBar._alpha)/10)/10*lrcBar.lrcBase.lrcText._width*1.5 : null;
} else if (lrcBar._alpha<=0) {
lrcBar.lrcBase._x = lrcBar.lrcOver._x=0;
curLrcId>=0 ? setLrcText() : null;
}
lrcBar.lrcOver.lrcText._width<lrcBar.lrcBase.lrcText._width ? lrcBar.lrcOver.lrcText._width += klokStepLong : lrcBar.lrcOver.lrcText._width=lrcBar.lrcBase.lrcText._width;
//lrcBar.lrcOver.lrcText._width<lrcBar.lrcBase.lrcText._width ? lrcBar.lrcOver.lrcText._width=lrcBar.lrcBase.lrcText._width*((getTimeMS(mp3Time)-getTimeMS(lrcItem[curLrcId].slice(0,7)))/(getTimeMS(lrcItem[curLrcId+1].slice(0,7))-getTimeMS(lrcItem[curLrcId].slice(0,7)))) : lrcBar.lrcOver.lrcText._width=lrcBar.lrcBase.lrcText._width;
updateAfterEvent();
}
function setLrcText() {
lrcBar.lrcBase.lrcText.text = lrcBar.lrcOver.lrcText.text=lrcItem[curLrcId].split(divsign)[1];
lrcBar.lrcBase.lrcText.setTextFormat(lrcTextFomart);
lrcBar.lrcOver.lrcText.setTextFormat(lrcTextFomart);
lrcBar.lrcOver.lrcText._x = lrcBar.lrcBase.lrcText._x;
lrcBar.lrcOver.lrcText._width = 0;
klokStepLong = lrcBar.lrcBase.lrcText._width/((getTimeMS(lrcItem[curLrcId+1].slice(0, 7))-getTimeMS(lrcItem[curLrcId].slice(0, 7)))/(Stage["displayState"] == "fullScreen" ? 50 : 45));
}
function switchFilterMode() {
if (lrcBarFilterMode == true) {
lrcBarFilterMode = false;
lrcBar.filters = [];
} else {
lrcBarFilterMode = true;
lrcBar.filters = [lrcBarBevelFilter, lrcBarDropShadowFilter];
}
}
function switchMotionMode() {
lrcMotionMode = !lrcMotionMode;
}
/*****************第四部分:加载LRC文件的功能****************/
var lrcLoader:LoadVars;
function loadLRC(lrcUrl:String) {
delete lrcLoader.onData;
lrcLoader = new LoadVars();
lrcLoader.onData = function(lrcStr) {
parseLRC(lrcStr);
trace(lrcItem.join("\n"));
curLrcId = -1;
clearInterval(lrcHander);
startLrcBarUpdate();
};
lrcLoader.load(lrcUrl);
}
function startLrcBarUpdate() {
lrcItem.length>0 ? lrcHander=setInterval(updateLrcBar, 30) : lrcBar.lrcBase.lrcText.text=lrcBar.lrcOver.lrcText.text="非常抱歉,此曲暂无歌词!";
}
/*****************第五部分:播放MP3列表的功能****************/
var mp3List:Array;
var mp3Sound:Sound;
var mp3Id:Number = -1;
var mp3CtrlHtml:String;
function playmp3(disVar:Number) {
clearInterval(lrcHander);
mp3Sound = new Sound(this);
mp3Sound.onSoundComplete = function() {
playmp3(1);
};
mp3Playing = true;
mp3Id = makeMp3Id(disVar);
mp3Sound.loadSound(mp3List[mp3Id].attributes.url,true);
lrcBar.lrcBase.lrcText.text = lrcBar.lrcOver.lrcText.text="";
mp3CtrlHtml = "<b>("+String(mp3Id+1)+"/"+mp3List.length+") "+mp3List[mp3Id].attributes.cap+" <font color='#cc0000'><a href='asfunction:playmp3,-1'><上一首</a> <a href='asfunction:pausemp3,1'>暂停/播放</a> <a href='asfunction:playmp3,1'>下一首></a> <a href='asfunction:switchFilterMode'>倒角投影淡入开关</a> <a href='asfunction:switchMotionMode'>动效开关</a> <a target='_blank' href='"+mp3List[mp3Id].attributes.lrc+"'>LRC</a>&nbsp;</font></b>";
mp3Cap.htmlText = mp3CtrlHtml;
loadLRC(mp3List[mp3Id].attributes.lrc);
loadMp3Img(mp3List[mp3Id].attributes.img);
}
function makeMp3Id(disVar:Number) {
var theid:Number = mp3Id+Number(disVar);
theid>mp3List.length-1 ? theid=0 : null;
theid<0 ? theid=mp3List.length-1 : null;
return theid;
}
var mp3Playing:Boolean;
var mp3PausePos:Number;
function pausemp3() {
clearInterval(lrcHander);
if (mp3Playing == true) {
mp3Playing = false;
mp3PausePos = mp3Sound.position/1000;
mp3Sound.stop();
} else {
mp3Playing = true;
mp3Sound.start(mp3PausePos,1);
startLrcBarUpdate();
}
}
/*****************第六部分:加载MP3配图的功能****************/
import flash.display.BitmapData;
var imgbitmapdata:BitmapData;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var fadestyle:Object = None.easeNone;
var fadeduration:Number = 0.5;
var fadeTween:Object;
var imgloader:MovieClipLoader = new MovieClipLoader();
var imgloadlistener:Object = new Object();
imgloader.addListener(imgloadlistener);
imgloadlistener.onLoadInit = function(target:MovieClip) {
imgbitmapdata = new BitmapData(target._width, target._height, true, 0xff0000);
imgbitmapdata.draw(target);
target.attachBitmap(imgbitmapdata,target.getNextHighestDepth(),"auto",true);
fadeTween = new Tween(mp3Img, "_alpha", fadestyle, mp3Img._alpha, 100, fadeduration, true);
fitmodels();
};
function loadMp3Img(imgUrl:String) {
fadeTween = new Tween(mp3Img, "_alpha", fadestyle, mp3Img._alpha, 0, fadeduration, true);
fadeTween.onMotionFinished = function() {
imgloader.unloadClip(mp3Img);
mp3Img._xscale = mp3Img._yscale=100;
imgloader.loadClip(imgUrl,mp3Img);
};
}
/*****************第七部分:创建LRC歌词条、播放控制链接等界面元素****************/
function createLrcCtrl() {
createEmptyMovieClip("mp3Img",getNextHighestDepth());
createEmptyMovieClip("lrcBar",getNextHighestDepth());
lrcBar.filters = [lrcBarBevelFilter, lrcBarDropShadowFilter];
lrcBar.createEmptyMovieClip("lrcBase",lrcBar.getNextHighestDepth());
lrcBar.createEmptyMovieClip("lrcOver",lrcBar.getNextHighestDepth());
lrcBar.lrcBase.createTextField("lrcText",lrcBar.lrcBase.getNextHighestDepth(),0,15,740,35);
lrcBar.lrcOver.createTextField("lrcText",lrcBar.lrcOver.getNextHighestDepth(),0,15,740,35);
lrcBar.lrcBase.lrcText.textColor = 0x3366ff;
lrcBar.lrcOver.lrcText.textColor = 0xff3300;
createTextField("mp3Cap",getNextHighestDepth(),0,65,740,20);
lrcBar.lrcBase.lrcText.autoSize = "center";
mp3Cap.autoSize = "right";
mp3Cap.html = true;
lrcBar._alpha = 0;
}
createLrcCtrl();
fitmodels();
/*****************第八部分:加载MP3列表的功能****************/
var mp3Xml:XML = new XML();
mp3Xml.ignoreWhite = true;
mp3Xml.onLoad = function(success) {
if (success) {
mp3List = this.firstChild.firstChild.childNodes;
playmp3(Math.ceil(Math.random()*mp3List.length));
}
};
mp3Xml.load("mp3list.xml");

2、新建文本文档,保存为mp3list.xml”,列表里面内容好下
?<?xml version="1.0" encoding="UTF-8"?>
<node cap="卡拉OK">
<node cap="蓝鸟收藏">
<node cap="大海" lrc="http://yun.365.sh/s/4ahkw2.txt" url="http://1.wp.zp68.com/sub/filestores/2016/07/29/626f44b691192fac3139f5a29235b012.mp3"/>

<node cap="我要一生跟你在起"  lrc="http://yun.365.sh/s/estSh.txt" url="http://1.wp.zp68.com/sub/filestores/2016/07/29/3c2ea3f9782251feb7dd2712638eedc1.mp3"/>
<node cap="蓝鸟收藏音乐" lrc="http://yun.365.sh/s/7bcca1.txt" url="http://1.wp.zp68.com/sub/filestores/2016/03/27/2373adbad8c6d1161a121807151a4257.mp3"/>

  <node cap="今生爱你不后悔" lrc="http://yun.365.sh/s/0iVSk3.txt" url="http://1.wp.zp68.com/sub/filestores/2016/03/24/15b68111d71eb98bf5267e6d0e56cee1.mp3"/>

</node>
</node>

注意:mp3list.xml”,另存编码为UTT-8格式才不出现乱码。



  评论这张
 
阅读(14)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017