Repository: flex-asjs Updated Branches: refs/heads/develop c8e368058 -> 84968b957
Some callback functions weren't being called properly on the flash side. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/84968b95 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/84968b95 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/84968b95 Branch: refs/heads/develop Commit: 84968b957207af7fc8e0dd7d60b10c7d269c4bb3 Parents: c8e3680 Author: yishayw <[email protected]> Authored: Thu Jul 14 11:50:59 2016 +0300 Committer: yishayw <[email protected]> Committed: Thu Jul 14 11:50:59 2016 +0300 ---------------------------------------------------------------------- .../flex/org/apache/flex/net/URLBinaryLoader.as | 72 ++++++++++++-------- .../main/flex/org/apache/flex/net/URLStream.as | 2 +- 2 files changed, 43 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/84968b95/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLBinaryLoader.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLBinaryLoader.as b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLBinaryLoader.as index b4a447a..4d5d293 100644 --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLBinaryLoader.as +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLBinaryLoader.as @@ -85,38 +85,49 @@ package org.apache.flex.net { super(); stream = new URLStream(); - stream.onProgress = function(stream:URLStream):void - { - bytesLoaded = stream.bytesLoaded; - bytesTotal = stream.bytesTotal; - dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,bytesLoaded,bytesTotal)); - if(onProgress) - onProgress(this); - } - stream.onStatus = function(stream:URLStream):void - { - requestStatus = stream.requestStatus; - dispatchEvent(new DetailEvent(HTTPConstants.STATUS,false,false,""+requestStatus)); - if(onStatus) - onStatus(this); - - } - stream.onError = function(stream:URLStream):void - { - dispatchEvent(new DetailEvent(HTTPConstants.COMMUNICATION_ERROR,false,false,""+requestStatus)); - if(onError) - onError(this); - cleanupCallbacks(); - } - stream.onComplete = function(stream:URLStream):void - { - dispatchEvent(new org.apache.flex.events.Event(HTTPConstants.COMPLETE)); - if(onComplete) - onComplete(); - cleanupCallbacks(); - } + } + private function progressFunction(stream:URLStream):void + { + bytesLoaded = stream.bytesLoaded; + bytesTotal = stream.bytesTotal; + dispatchEvent(new ProgressEvent(ProgressEvent.PROGRESS,false,false,bytesLoaded,bytesTotal)); + if(onProgress) + onProgress(this); + } + + private function statusFunction(stream:URLStream):void + { + requestStatus = stream.requestStatus; + dispatchEvent(new DetailEvent(HTTPConstants.STATUS,false,false,""+requestStatus)); + if(onStatus) + onStatus(this); } + private function errorFunction(stream:URLStream):void + { + dispatchEvent(new DetailEvent(HTTPConstants.COMMUNICATION_ERROR,false,false,""+requestStatus)); + if(onError) + onError(this); + cleanupCallbacks(); + } + + private function completeFunction(stream:URLStream):void + { + data = stream.response; + dispatchEvent(new org.apache.flex.events.Event(HTTPConstants.COMPLETE)); + if(onComplete) + onComplete(this); + cleanupCallbacks(); + } + + private function setupCallbacks():void + { + stream.onProgress = progressFunction; + + stream.onStatus = statusFunction; + stream.onError = errorFunction; + stream.onComplete = completeFunction; + } /** * Makes the URL request. * @@ -127,6 +138,7 @@ package org.apache.flex.net */ public function load(request:URLRequest):void { + setupCallbacks(); stream.load(request); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/84968b95/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as index d10c375..8bfac15 100644 --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as @@ -108,7 +108,7 @@ package org.apache.flex.net var hdr:URLRequestHeader = new URLRequestHeader("Content-type", urlRequest.contentType); req.requestHeaders.push(hdr); req.data = new flash.net.URLVariables(HTTPUtils.encodeUrlVariables(urlRequest.data)); - req.method = HTTPConstants.POST; + req.method = urlRequest.method; flashUrlStream.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, flash_status); flashUrlStream.addEventListener(HTTPStatusEvent.HTTP_STATUS, flash_status); flashUrlStream.addEventListener(flash.events.ProgressEvent.PROGRESS, flash_progress);
