You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/11/18 07:21:12 UTC
[royale-asjs] branch develop updated: More tuning to progress
tracking in URLLoader
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 4d45114 More tuning to progress tracking in URLLoader
4d45114 is described below
commit 4d4511493647124d3ea22603bd2c3a48893678f7
Author: greg-dove <gr...@gmail.com>
AuthorDate: Wed Nov 18 20:09:20 2020 +1300
More tuning to progress tracking in URLLoader
---
.../main/royale/org/apache/royale/net/URLLoader.as | 23 +++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
index ae722c1..ab48da6 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLLoader.as
@@ -140,6 +140,8 @@ package org.apache.royale.net
*/
public function load(request:org.apache.royale.net.URLRequest):void
{
+ bytesLoaded = 0;
+ bytesTotal = 0;
// copied from HTTPService
COMPILE::SWF
{
@@ -201,8 +203,15 @@ package org.apache.royale.net
COMPILE::JS
{
var element:XMLHttpRequest = this.element as XMLHttpRequest;
- element.onreadystatechange = progressHandler;
- element.onprogress = jsLoadProgressHandler;
+ if (!element.onreadystatechange){
+ element.onreadystatechange = progressHandler;
+ var commonHandler:Function = jsEventHandler;
+ element.onprogress = commonHandler;
+ element.onloadstart = commonHandler;
+ element.onloadend = commonHandler;
+ element.onload = commonHandler;
+ }
+
var url:String = request.url;
/*
@@ -340,13 +349,13 @@ package org.apache.royale.net
}
COMPILE::JS
- protected function jsLoadProgressHandler(e:window.ProgressEvent):void{
- if (e.lengthComputable) {
+ protected function jsEventHandler(e:window.ProgressEvent):void{
+ if (e.loaded) {
+ //there is some quantity of loaded bytes, but bytesTotal may be unknown (e.lengthComputable)
bytesLoaded = e.loaded;
- bytesTotal = e.total;
- trace('loadProgressHandler', bytesLoaded, bytesTotal);
+ bytesTotal = e.lengthComputable ? e.total : 0;
//avoid instantiation and dispatch unless we are being listened to
- if (hasEventListener(org.apache.royale.events.ProgressEvent.PROGRESS))
+ if (e.type=='progress' && hasEventListener(org.apache.royale.events.ProgressEvent.PROGRESS))
dispatchEvent(new org.apache.royale.events.ProgressEvent(org.apache.royale.events.ProgressEvent.PROGRESS,false,false,bytesLoaded,bytesTotal ))
} else {
bytesLoaded = 0;