You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2016/07/10 06:03:08 UTC
git commit: [flex-asjs] [refs/heads/develop] - Finished callbacks in
URLLoader classes
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 <ha...@in-tools.com>
Authored: Sun Jul 10 09:03:01 2016 +0300
Committer: Harbs <ha...@in-tools.com>
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