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

《电脑之家》

请点击:“日志”浏览电脑知识

 
 
 

日志

 
 

用AS代码画成的三格播放器  

2011-06-01 08:31:07|  分类: flash素材 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
 
制作教程和步骤:
1:打开flash 8软件,在图层1的第一帧动作面板输入下面的AS指令。【设置画布大小250x50即可】
2:添加自己喜欢的歌曲:  歌曲地址在代码从底部数第9行。
=============复制下面红色部分AS代码,拿回去再操作上面1、2两步OK!===================
=====================================代码如下===================================
 
//循环播放
my_sound.onSoundComplete = function() {
my_sound.start();
};
//创建音量底线
this.createEmptyMovieClip("xing_mc", 1);
with (xing_mc) {
beginFill(0xff0000);
moveTo(46, 11);
lineTo(75, 11);
lineTo(75, 12);
lineTo(46, 12);
lineTo(46, 11);
endFill();
}
this.createEmptyMovieClip("xin_mc", 2);//方框中间分割线;
with (xin_mc) {
beginFill(0x008800);
moveTo(0, 14);
lineTo(235, 14);
lineTo(235, 15);
lineTo(0, 15);
lineTo(0, 14);
endFill();
}
//创建背景方框
this.createEmptyMovieClip("fangkang_mc", 3);
with (fangkang_mc) {
lineStyle(1, 0x008800);
moveTo(0, 0);
lineTo(235, 0); //背景方框的长度235;
lineTo(235, 28);
lineTo(0, 28);
lineTo(0, 0);
}
//创建音量滑块并控制音量
this.createEmptyMovieClip("drag_mc", 4);
with (drag_mc) {
beginFill(0x008800);
moveTo(46, 3);
lineTo(50, 3);
lineTo(50, 12);
lineTo(46, 12);
lineTo(46, 3);
endFill();
}
left = drag_mc._x;
right = left+30; //音量滑块长度
top = drag_mc._y;
bottom = drag_mc._y;
drag_mc._x = my_sound.getVolume();
drag_mc._x = 30; //音量滑块长度
drag_mc.onPress = function() {
this.startDrag(false, left, top, right, bottom);
};
drag_mc.onRelease = drag_mc.onReleaseOutside=function () {
stopDrag();
my_sound.setVolume((this._x)*2);
};
//按钮的可见性
pause_mc._visible = 1;
play_mc._visible = 0;
//创建播放按钮
this.createEmptyMovieClip("play_mc", 5);
with (play_mc) {
beginFill(0x008800);
moveTo(5, 3);
lineTo(14, 7.5);
lineTo(5, 12);
lineTo(5, 3);
endFill();
}
play_mc.onRelease = function() {
my_sound.start(time);
this._visible = 0;
pause_mc._visible = 1;
};
//创建停止按钮
this.createEmptyMovieClip("stop_mc", 6);
with (stop_mc) {
beginFill(0x008800);
moveTo(25, 3);
lineTo(34, 3);
lineTo(34, 12);
lineTo(25, 12);
lineTo(25, 3);
endFill();
}
stop_mc.onRelease = function() {
my_sound.stop();
pause_mc._visible = 0;
play_mc._visible = 1;
time=0
};
//创建暂停按钮
this.createEmptyMovieClip("pause_mc", 7);
with (pause_mc) {
beginFill(0x008800);
moveTo(5, 3);
lineTo(14, 3);
lineTo(14, 12);
lineTo(5, 12);
lineTo(5, 3);
endFill();
beginFill(0x008800);//暂停“||”;
moveTo(8, 3);
lineTo(11, 3);
lineTo(11, 12);
lineTo(8, 12);
lineTo(8, 3);
endFill();
}
pause_mc.onRelease = function() {
this._visible = 0;
play_mc._visible = 1;
my_sound.stop();
time = my_sound.position/1000;
};
//创建进度显示文本
this.createTextField("shijian_txt", 7, 80, -2, 100, 20);
shijian_txt.textColor = 0x008800;
shijian_txt.autoSize = true;
onEnterFrame = function () {
var totalseconds:Number = my_sound.duration/1000;
var minutes:Number = Math.floor(totalseconds/60);
var seconds = Math.floor(totalseconds)%60;
if (seconds<10) {
  seconds = "0"+seconds;
}
var playedseconds:Number = my_sound.position/1000;
var minutesed:Number = Math.floor(playedseconds/60);
var secondsed = Math.floor(playedseconds)%60;
if (secondsed<10) {
  sec+secondsed;
}
shijian_txt.text = minutesed+":"+secondsed+"—"+minutes+":"+seconds+"(自然醒上传)";
};
//@执行下一组as指令;
var pb_height:Number = 14;//设置宽高变量
var pb_width:Number = 235;
var pb:MovieClip = this.createEmptyMovieClip("progressBar_mc", this.getNextHighestDepth());//在影片剪辑pb中创建进度
pb.createEmptyMovieClip("bar_mc", pb.getNextHighestDepth());//在影片剪辑pb中创建进度条
pb.createEmptyMovieClip("vBar_mc", pb.getNextHighestDepth());//在影片剪辑pb中创建进度条右边直线
pb.createEmptyMovieClip("stroke_mc", pb.getNextHighestDepth());//在影片剪辑pb中创建进度框
pb.createTextField("pos_txt", pb.getNextHighestDepth(), 0, pb_height, pb_width, 22);//在影片剪辑pb中创建动态文本
pb._x = 0;//影片剪辑pb的坐标设置
pb._y = 28;
with (pb.bar_mc) {
   beginFill(0x008800);//画进度条
   moveTo(0, 0);
   lineTo(pb_width, 0);
   lineTo(pb_width, pb_height);
   lineTo(0, pb_height);
   lineTo(0, 0);
   endFill();
   _xscale = 0;
}
with (pb.vBar_mc) {
   lineStyle(1, 0x008800);//画进度条右边直线
   moveTo(0, 0);
   lineTo(0, pb_height);
}
with (pb.stroke_mc) {
   lineStyle(1, 0x008800);//画进度框
   moveTo(0, 0);
   lineTo(pb_width, 0);
   lineTo(pb_width, pb_height);
   lineTo(0, pb_height);
   lineTo(0, 0);
}
var my_interval:Number;//设置一些变量
var my_sound:Sound = new Sound();
//加载声音自动调用
my_sound.onLoad = function(success:Boolean) {
   if (success) {
      trace("sound loaded");
   }
};
//声音播放完毕时调用
my_sound.onSoundComplete = function() {
   clearInterval(my_interval);
   trace("Cleared interval");
}
//加载声音路径
my_sound.loadSound("
http://www.clep.org.cn/upfile/Sbj_000/2007/06/200768151339988.mp3", true);
//每隔一定时间就调用下面的updateProgressBar函数
my_interval = setInterval(updateProgressBar, 100, my_sound);
function updateProgressBar(the_sound:Sound):Void {
//设置声音进度(声音已播放时间除以声音总时间乘以100)
   var pos:Number = Math.round(the_sound.position / the_sound.duration * 100);
   pb.bar_mc._xscale = pos;//进度条进行缩放
   pb.vBar_mc._x = pb.bar_mc._width;//进度条右边直线的X坐标等于进度条的宽
}
【出品:
自然醒网站
自然醒推荐阅读:
  评论这张
 
阅读(358)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

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

页脚

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