此进度条无效。知道为什么吗?
import flash.filesystem.*;
import flash.display.*;
var byteArray:ByteArray = new ByteArray();//Bytes from the URLStream will go here
var loader:Loader = new Loader();
var urlString:String = "http://massmediamail.com/testing/Rosary.zip";
var urlReq:URLRequest = new URLRequest(urlString);
var urlStream:URLStream = new URLStream();
var fileData:ByteArray = new ByteArray();
urlStream.addEventListener(Event.COMPLETE, loaded);
urlStream.load(urlReq);
function loaded(event:Event):void
{
urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
writeAirFile();
}
function writeAirFile():void
{
var file:File = File.applicationStorageDirectory.resolvePath("000Zip/Rosary.zip");
trace(File.applicationStorageDirectory.nativePath);
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(fileData, 0, fileData.length);
fileStream.close();
trace("The file is written.");
done.text = "Yahoooo!";
more.text = "Now wait for the \"yippie!\"";
//TotalLoaded.text = "Downloaded Zip";
fileStream.addEventListener(ProgressEvent.PROGRESS, onStreamProgress, false, 0, true);
function onStreamProgress(event:ProgressEvent):void
{
TotalBytes.text = "" + event.bytesTotal + "";
bb.text = "" + event.bytesLoaded + "";
}
}
答案 0 :(得分:1)
将其附加到URL Stream,而不是FileStream