Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id ACF49200B4E for ; Sun, 10 Jul 2016 08:03:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A83BA160A74; Sun, 10 Jul 2016 06:03:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C75B4160A67 for ; Sun, 10 Jul 2016 08:03:09 +0200 (CEST) Received: (qmail 86273 invoked by uid 500); 10 Jul 2016 06:03:08 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 86265 invoked by uid 99); 10 Jul 2016 06:03:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Jul 2016 06:03:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A8DBDDFDD3; Sun, 10 Jul 2016 06:03:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: harbs@apache.org To: commits@flex.apache.org Message-Id: <5aec564148b648b1922ffec60262c0d4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: [flex-asjs] [refs/heads/develop] - Finished callbacks in URLLoader classes Date: Sun, 10 Jul 2016 06:03:08 +0000 (UTC) archived-at: Sun, 10 Jul 2016 06:03:10 -0000 Repository: flex-asjs Updated Branches: refs/heads/develop ed45c5b41 -> c62ce094c Finished callbacks in URLLoader classes Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/c62ce094 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/c62ce094 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/c62ce094 Branch: refs/heads/develop Commit: c62ce094c1712d59934b1e84cc8c54616dd4d249 Parents: ed45c5b Author: Harbs Authored: Sun Jul 10 09:03:01 2016 +0300 Committer: Harbs Committed: Sun Jul 10 09:03:01 2016 +0300 ---------------------------------------------------------------------- .../flex/org/apache/flex/net/URLBinaryLoader.as | 42 +++++++++++---- .../main/flex/org/apache/flex/net/URLLoader.as | 55 ++++++++++++++------ .../main/flex/org/apache/flex/net/URLStream.as | 22 +++----- 3 files changed, 77 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c62ce094/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 e677245..b4a447a 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 @@ -19,6 +19,7 @@ package org.apache.flex.net { + import org.apache.flex.events.DetailEvent; import org.apache.flex.events.Event; import org.apache.flex.events.ProgressEvent; import org.apache.flex.utils.BinaryData; @@ -48,16 +49,6 @@ package org.apache.flex.net public var data:BinaryData; /** - * The status of the request. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.7.0 - */ - public var status:String; - - /** * Indicates the byte order for the data. * * @langversion 3.0 @@ -94,7 +85,36 @@ package org.apache.flex.net { super(); stream = new URLStream(); - stream.addEventListener(HTTPConstants.COMPLETE, completeHandler); + 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(); + } } /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c62ce094/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLLoader.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLLoader.as b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLLoader.as index 29a804c..069ecf2 100644 --- a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLLoader.as +++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLLoader.as @@ -43,7 +43,7 @@ package org.apache.flex.net * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - [Event(name="ioError", type="org.apache.flex.events.Event")] + [Event(name="communicationError", type="org.apache.flex.events.Event")] /** * Dispatched when an httpStatus code is received from the server. @@ -56,22 +56,6 @@ package org.apache.flex.net [Event(name="httpStatus", type="org.apache.flex.events.Event")] /** - * Dispatched if Adobe AIR is able to detect and return the status - * code for the request. Unlike the httpStatus event, the httpResponseStatus - * event is delivered before any response data. Also, the httpResponseStatus - * event includes values for the responseHeaders and responseURL properties - * (which are undefined for an httpStatus event. Note that the - * httpResponseStatus event (if any) will be sent before - * (and in addition to) any complete or error event. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Event(name="httpResponseStatus", type="org.apache.flex.events.Event")] - - /** * The URLLoader class is a base class for the specific flavors of loaders such as binary, * text or variables * @@ -86,11 +70,23 @@ package org.apache.flex.net { } + /** + * The status of the request. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7.0 + */ + public var requestStatus:int; + + protected function cleanupCallbacks():void { onComplete = null; onError = null; onProgress = null; + onStatus = null; } /** * Callback for complete event. @@ -123,6 +119,16 @@ package org.apache.flex.net public var onProgress:Function; /** + * Callback for status event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7.0 + */ + public var onStatus:Function; + + /** * Convenience function for complete event to allow chaining. * * @langversion 3.0 @@ -163,5 +169,20 @@ package org.apache.flex.net onProgress = callback; return this; } + + /** + * Convenience function for status event to allow chaining. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7.0 + */ + public function status(callback:Function):URLLoader + { + onStatus = callback; + return this; + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c62ce094/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 0d27b68..c67b334 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 @@ -18,13 +18,6 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.net { - - - - import flash.events.HTTPStatusEvent; - import flash.events.SecurityErrorEvent; - import flash.events.StatusEvent; - import org.apache.flex.events.DetailEvent; import org.apache.flex.events.Event; import org.apache.flex.events.EventDispatcher; @@ -34,18 +27,19 @@ package org.apache.flex.net COMPILE::SWF { - import flash.net.URLRequestHeader; + import flash.events.Event; + import flash.events.HTTPStatusEvent; import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; + import flash.events.SecurityErrorEvent; + import flash.events.StatusEvent; + import flash.net.URLRequest; + import flash.net.URLRequestHeader; + import flash.net.URLStream; import flash.net.URLVariables; - import flash.events.Event; - import flash.events.ProgressEvent; - import flash.net.URLRequest; - import flash.net.URLStream; import flash.utils.ByteArray; } - - public class URLStream extends EventDispatcher { COMPILE::JS