首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

简略的mp3播放器

2012-10-24 
简单的mp3播放器很简单的播放器,不过可以作为一种思路哦.import flash.media.Soundimport flash.events.E

简单的mp3播放器
很简单的播放器,不过可以作为一种思路哦.

import flash.media.Sound;import flash.events.Event;import flash.media.SoundChannel;import flash.display.Sprite;import flash.events.MouseEvent;import flash.net.URLRequest;var sound:Sound = new Sound();sound.load(new URLRequest("d:/Temp/b.mp3"));var sc:SoundChannel = sound.play();addEventListener(Event.ENTER_FRAME,loop);function loop(e:Event):void{track.scaleX = sc.position/sound.length;}//trackvar w:int = 550;var h:int = 400;var track_y:int = h - 20;var track:Sprite = new Sprite();addChild(track);track.y = track_y;track.graphics.beginFill(0xff0000);track.graphics.drawRoundRect(0,0,w,h,4,4);track.graphics.endFill();track.scaleX = 0;track.mouseChildren = false;//progressvar progress:Sprite = new Sprite();addChild(progress);progress.y = track_y;progress.graphics.beginFill(0xCCCCCC,.4);progress.graphics.drawRoundRect(0,0,w,h,4,4);progress.graphics.endFill();progress.addEventListener(MouseEvent.CLICK,onClick);function onClick(e:MouseEvent):void{sc.stop();sc = sound.play( (progress.mouseX/w) * sound.length);}

热点排行