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/12 13:54:42 UTC
git commit: [flex-asjs] [refs/heads/develop] - Added writeByteAt and
fromString to BinaryData
Repository: flex-asjs
Updated Branches:
refs/heads/develop 686bd3f3f -> 4541fff26
Added writeByteAt and fromString to BinaryData
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4541fff2
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4541fff2
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4541fff2
Branch: refs/heads/develop
Commit: 4541fff26eadefcf16666ad68c5fb881c1119bc4
Parents: 686bd3f
Author: Harbs <ha...@in-tools.com>
Authored: Tue Jul 12 16:54:36 2016 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Tue Jul 12 16:54:36 2016 +0300
----------------------------------------------------------------------
.../flex/org/apache/flex/utils/BinaryData.as | 40 +++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4541fff2/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/BinaryData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/BinaryData.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/BinaryData.as
index 1e00af2..ab750c9 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/BinaryData.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/BinaryData.as
@@ -56,6 +56,21 @@ public class BinaryData
{
ba = bytes ? bytes : new ArrayBuffer(0);
}
+
+ /**
+ * Utility method to create a BinaryData object from a string.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.7.0
+ */
+ public static function fromString(str:String):BinaryData
+ {
+ var bd:BinaryData = new BinaryData();
+ bd.writeUTFBytes(str);
+ return bd;
+ }
private var _endian:String = Endian.DEFAULT;
@@ -285,7 +300,30 @@ public class BinaryData
{
private var typedArray:Uint8Array;
}
-
+
+ /**
+ * Writes a byte of binary data at the specified index. Does not change the <code>position</code> property.
+ * This is a method for optimzed writes with no range checking.
+ * If the specified index is out of range, it can throw an error.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function writeByteAt(idx:uint,byte:int):void
+ {
+ COMPILE::SWF
+ {
+ ba[idx] = byte;
+ }
+ COMPILE::JS
+ {
+ if(typedArray == null)
+ typedArray = new Uint8Array(ba);
+ typedArray[idx] = byte;
+ }
+ }
/**
* Read a short int of binary data at the current position