Flash AS3教程:ByteLoader类

2019-10-08 17:56:35于丽

}

//加载中
private function progressFun(e:ProgressEvent):void{
if(stream.bytesAvailable == 0) return;
updata();
dispatchEvent(e);
}

//加载完成
private function completeFun(e:Event):void{
stream.removeEventListener(Event.COMPLETE,completeFun);
stream.removeEventListener(ProgressEvent.PROGRESS,progressFun);
updata();
if(isLoad) stream.close();
dispatchEvent(e);
}

//更新数据
public function updata():void{
if(isLoad) stream.readBytes(data,data.length);
}

//清除数据
public function close():void{
if(isLoad) stream.close();
stream = null;
data = null;
}

//获取是否有数据在加载
public function get isLoad():Boolean{
if(stream == null) return false;
return stream.connected;
}
}
}