From 5167b875aaee2b047be4a5b7861cf4832f583fe9 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 24 Nov 2015 23:32:49 -0800 Subject: [PATCH] JS byte fixes --- lime/app/Preloader.hx | 2 ++ lime/net/HTTPRequest.hx | 5 +++-- lime/utils/Bytes.hx | 10 +++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lime/app/Preloader.hx b/lime/app/Preloader.hx index a15030df9..a96571726 100644 --- a/lime/app/Preloader.hx +++ b/lime/app/Preloader.hx @@ -91,6 +91,7 @@ class Preloader #if flash extends Sprite #end { if (!loaders.exists (url)) { var loader = new HTTPRequest (); + loaders.set (url, loader); total++; } @@ -100,6 +101,7 @@ class Preloader #if flash extends Sprite #end { if (!loaders.exists (url)) { var loader = new HTTPRequest (); + loaders.set (url, loader); total++; } diff --git a/lime/net/HTTPRequest.hx b/lime/net/HTTPRequest.hx index 7aaf4d6c4..479de81fc 100644 --- a/lime/net/HTTPRequest.hx +++ b/lime/net/HTTPRequest.hx @@ -50,7 +50,8 @@ class HTTPRequest { if (request.status != null && request.status >= 200 && request.status <= 400) { - promise.complete (Bytes.ofData (request.response)); + bytes = Bytes.ofData (request.response); + promise.complete (bytes); } else { @@ -62,7 +63,7 @@ class HTTPRequest { request.open ("GET", url, true); request.responseType = ARRAYBUFFER; - request.send (null); + request.send (""); #else diff --git a/lime/utils/Bytes.hx b/lime/utils/Bytes.hx index ef3081d8d..62a882ff8 100644 --- a/lime/utils/Bytes.hx +++ b/lime/utils/Bytes.hx @@ -16,7 +16,11 @@ class Bytes extends HaxeBytes { public function new (length:Int, bytesData:BytesData) { + #if js + super (bytesData); + #else super (length, bytesData); + #end } @@ -24,7 +28,7 @@ class Bytes extends HaxeBytes { public static function alloc (length:Int):Bytes { var bytes = HaxeBytes.alloc (length); - return new Bytes (bytes.length, bytes.b); + return new Bytes (bytes.length, bytes.getData ()); } @@ -39,7 +43,7 @@ class Bytes extends HaxeBytes { public static function ofData (b:BytesData):Bytes { var bytes = HaxeBytes.ofData (b); - return new Bytes (bytes.length, bytes.b); + return new Bytes (bytes.length, bytes.getData ()); } @@ -47,7 +51,7 @@ class Bytes extends HaxeBytes { public static function ofString (s:String):Bytes { var bytes = HaxeBytes.ofString (s); - return new Bytes (bytes.length, bytes.b); + return new Bytes (bytes.length, bytes.getData ()); }