|
public class jzjd extends Sprite {
private var subLoader:Loader;
public function jzjd():void {
subLoader = new Loader();
//新建一个 loader 事件
subLoader.load(new URLRequest("http://www.xajggw.cn/mov/wma/dahai.mp3"));
//把你要的文件加载进来
subLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
//进度监听
subLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
//完成执行的事件
}
private function progressHandler(e:ProgressEvent):void {
var loaded:Number = e.bytesLoaded;
var total:Number = e.bytesTotal;
var all:Number = Math.round(loaded/total*100);
var jd:Number = Math.round(loaded/total*2);
var loadpre:int=e.bytesLoaded/e.bytesTotal*100;
//这个其实进度数除以总数乘以100就是让他变成整数
jz_txt.text=("读取了 : " + loaded);
bfb_txt.text= "loading..."+loadpre+"%";
zdx_txt.text= "文件总大小为:"+e.bytesTotal+" 字节";
jz_mc.scaleX=loadpre/100;
if (all >=100){
//当all大于100的时间执行别的事件 于下面的 completeHandler 一样
trace("加载完成")
}
}
private function completeHandler(event:Event):void {
trace( "文件已经加载完成");
}
}
本文由胡金金个人网站整理发布,转载请注明地址:http://www.hujinjin.com/info/97.html