I upload some data to my server with the help of URLLoader, and I listen to the ProgressEvent, but it doesn't dispatch. No errors, files get uploaded successfully. Why could it not work?
Code as follows:
//setup
urlLoader.addEventListener开发者_StackOverflow中文版(ProgressEvent.PROGRESS, onProgress);
//listen
private function onProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + ' ' + e.bytesTotal);
}
I'm late to this answer, but seeing as how I just ran into it myself, I thought I'd add my two cents:
The reason you are not seeing any progress events for a POST/upload is because the URLLoader doesn't dispatch progress events (or change the "bytesLoaded" property) for uploads. Sad, but true.
You don't show when you're actually calling the load() method. It should be :
//setup
urlLoader.addEventListener(ProgressEvent.PROGRESS, onProgress);
urlLoader.load( new URLRequest( url ) );
//listen
private function onProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + ' ' + e.bytesTotal);
}
I presume the urlLoader is a loader object instance? If so you need to add the eventListener to the contentLoaderInfo property.
urlLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
精彩评论