var dizhi:URLRequest=new URLRequest("http://www.qqkjc.com/mp3/09072502.mp3") //远程声音地址 var shengyin:Sound=new Sound()
/*
*author : SinSoul *blogs: http://www.cnblogs.com/sinsoul
*/
shengyin.load(dizhi) //加载声音 shengyin.play() shengyin.addEventListener(Event.OPEN,jiazai) //监听声音加载事件 shengyin.addEventListener(ProgressEvent.PROGRESS,jiazaizh) shengyin.addEventListener(Event.COMPLETE,wancheng) shengyin.addEventListener(IOErrorEvent.IO_ERROR,shibai) function jiazai(evt:Event) //声音加载事件函数 { trace("开始加载") } function jiazaizh(evt:ProgressEvent) { jd_txt.text="加载了"+Math.round((evt.bytesLoaded/evt.bytesTotal)*100)+"%" //定义动态文本jd_txt jdt.gotoAndStop(Math.round((evt.bytesLoaded/evt.bytesTotal)*100)) //jdt是进度条,影片剪辑,从1 到100幁变长 } function wancheng(evt:Event) { trace("加载已经完成") } function shibai(evt:IOErrorEvent) { trace("加载失败") }