//申明变量 var _sound:Sound=new Sound(); var _channel:SoundChannel=new SoundChannel(); var loaded:int; var total:int; var _length:int; var position:int; var percentBuffered:Number; var percentPlayed:Number; //载入MP3并播放 var url:String="****.mp3";//你电脑上的MP3音乐文件名,把该文件与MP3音乐文件放在一个文件夹内。 var _request:URLRequest = new URLRequest(url); _sound.load(_request); _channel=_sound.play(); bfjdt_mc.visible=false; //添加不断更新监听事件 addEventListener(Event.ENTER_FRAME,yx); function yx(event:Event):void { loaded=_sound.bytesLoaded; total=_sound.bytesTotal; _length=_sound.length; position=_channel.position; percentBuffered=loaded / total; //jzjdt_mc.scaleX= percentBuffered;//因播放的是本地MP3,故不需求加载进度显示。 _length/=percentBuffered; percentPlayed=position / _length; bfjdt_mc.scaleX=percentPlayed; bfjdt_mc.visible=true; } if (percentBuffered>=1) { jdcz_btn.addEventListener(MouseEvent.CLICK,jdcz); } } //播放进度控制 function jdcz(e:MouseEvent):void { _channel.stop(); var bfjdbfb:Number=(mouseX-26)/200; bfjdt_mc.scaleX=bfjdbfb; position =_length*bfjdbfb; _channel=_sound.play(position); }