网页教学网
 当前位置: 网页教学网 >> 动画制作 >> Flash action技术 >> 阅读:Flash教程:纯AS制作简单的MP3播放器
[ HTML ] [ FW ] [ DW ] [ FP ] [ JS ] [ XML ] [ CSS ] [ 图象 ] [ FLASH ] [ .NET ] [ ASP ] [ JSP ] [ PHP ] [ 数据 ] [ 系统 ] [ 安全 ] [ 素材 ] [ 建站 ] [ 主机 ] [ 入门 ] [ 技巧 ]

Flash教程:纯AS制作简单的MP3播放器

http://www.webjx.com  更新日期:2007-08-15 22:12  出处:闪吧论坛  作者:qinz
  我终于用纯AS做了个简单MP3播放器,请大家指点!
效果见我的网页中http://qzgzs.51.net/flash/ASmp3player.html

下面没有嵌入网页中,所以不能正常播放。

把下面的代码复制到第一帧即可:
fscommand("fullscreen", false);
fscommand("allowscale", false);
fscommand("showmenu", false);
//加载外部声音
my_sound = new Sound();
my_sound.loadSound("http://bbs.wybstv.com.cn/v/春暖花开.mp3", true);
my_sound.start();
//循环播放
my_sound.onSoundComplete = function() {
my_sound.start();
};
//创建音量底线
this.createEmptyMovieClip("xing_mc", 1);
with (xing_mc) {
beginFill(0x009900);
moveTo(46, 11);
lineTo(100, 11);
lineTo(100, 12);
lineTo(46, 12);
lineTo(46, 11);
endFill();
}
//创建背景方框
this.createEmptyMovieClip("fangkang_mc", 2);
with (fangkang_mc) {
lineStyle(1, 0x008800);
moveTo(0, 0);
lineTo(260, 0);
lineTo(260, 14);
lineTo(0, 14);
lineTo(0, 0);
}
//创建音量滑块并控制音量
this.createEmptyMovieClip("drag_mc", 3);
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+50;
top = drag_mc._y;
bottom = drag_mc._y;
drag_mc._x = my_sound.getVolume();
drag_mc._x = 50;
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", 4);
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", 5);
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", 6);
with (pause_mc) {
beginFill(0x008800);
moveTo(5, 3);
lineTo(14, 3);
lineTo(14, 12);
lineTo(5, 12);
lineTo(5, 3);
endFill();
beginFill(0xFFFFFF);
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, 112, -2, 100, 20);
shijian_txt.textColor = 0x009900;
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+"(刘常制作)";
};
源文件:点击这里下载源文件
关键词:flash教程,as
推荐给好友】【关闭】【收藏本文
最新五条评论
查看全部评论
评论总数 0
您的评论
用户名: 新注册) 密 码: 匿名:
·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为
站内搜索
相关文章
推荐文章