These methods enable you to read data from the data stream into variables of specific data types and write from specific data types directly to the binary data stream. For example, the following code reads a simple array of strings and floating-point numbers and writes each element to a ByteArray. The organization of the array allows the code to call the appropriate ByteArray methods writeUTFBytes and writeFloat to write the data. The repeating data pattern makes it possible to read the array with a loop. Notice that you can set the position property to a specific location in the ByteArray to read or write at that offset.
|Published (Last):||2 February 2012|
|PDF File Size:||2.23 Mb|
|ePub File Size:||6.56 Mb|
|Price:||Free* [*Free Regsitration Required]|
The entire byte array is compressed. After the call, the length property of the ByteArray is set to the new length. The position property is set to the end of the byte array. You specify a compression algorithm by passing a value defined in the CompressionAlgorithm class as the algorithm parameter.
The deflate compression algorithm is used in several compression formats, such as zlib, gzip, some zip implementations, and others. When data is compressed using one of those compression formats, in addition to storing the compressed version of the original data, the compression format data for example, the. For example, when a ByteArray is compressed using the zlib algorithm, the resulting ByteArray is structured in a specific format.
Certain bytes contain metadata about the compressed data, while other bytes contain the actual compressed version of the original ByteArray data. As defined by the zlib compressed data format specification, those bytes that is, the portion containing the compressed version of the original data are compressed using the deflate algorithm.
Consequently those bytes are identical to the result of calling compress air. However, the result from compress air. First, you must separate the metadata from the compressed data, and you can then use the deflate format to decompress the compressed data. Valid values are defined as constants in the CompressionAlgorithm class. The default is to use zlib format. Calling compress CompressionAlgorithm.
Support for the lzma algorithm was added for Flash Player You must have those player versions, or later, to use lzma compression.
Related API Elements.
Working with ActionScript ByteArray objects
Subscribe to RSS
AS3 Personnalisé Objet ByteArray alors pour Objet Personnalisé