Package | mx.core |
Class | public class ByteArrayAsset |
Inheritance | ByteArrayAsset ByteArray Object |
Implements | IFlexAsset |
Language Version: | ActionScript 3.0 |
Product Version: | Flex 3 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
The byte data that you are embedding can be in any kind of file, and the entire file is always embedded. You cannot embed the bytes of a particular asset that is in a SWF file, although you can embed an entire SWF file.
The MXML compiler autogenerates a class that extends ByteArrayAsset to represent the embedded data.
To embed an arbitrary file, you declare a variable of type Class,
and put [Embed]
metadata on it, using the MIME type
application/octet-stream
.
For example, you embed a text file like this:
[Bindable] [Embed(source="Story.txt", mimeType="application/octet-stream")] private var storyClass:Class;
The compiler autogenerates a subclass of the ByteArrayAsset class
and sets your variable to be a reference to this autogenerated class.
You can then use this class reference to create instances of the
ByteArrayAsset using the new
operator, and you can extract
information from the byte array using methods of the ByteArray class:
var storyByteArray:ByteArrayAsset = ByteArrayAsset(new storyClass()); var story:String = storyByteArray.readUTFBytes(storyByteArray.length);
You must specify that the MIME type for the embedding is
application/octet-stream
, which causes the byte data
to be embedded "as is", with no interpretation.
It also causes the autogenerated class to extend ByteArrayAsset
rather than another asset class.
For example, if you embed a PNG file without specifying this
MIME type, the PNG data will be automatically transcoded
into the bitmap format used by the player, and a subclass
of BitmapAsset will be autogenerated to represent it.
But if you specify the MIME type as application/octet-stream
,
then no transcoding will occur, the PNG data will be embedded
as is, and the autogenerated class will extend ByteArrayAsset.
Method | Defined By | ||
---|---|---|---|
Constructor. | ByteArrayAsset | ||
In a single atomic operation, compares an integer value in this
byte array with another integer value and, if they match, swaps those
bytes with another value. | ByteArray | ||
In a single atomic operation, compares this byte array's length with a
provided value and, if they match, changes the length of this byte array. | ByteArray | ||
Clears the contents of the byte array and resets the length
and position properties to 0. | ByteArray | ||
Compresses the byte array. | ByteArray | ||
Compresses the byte array using the deflate compression algorithm. | ByteArray | ||
Indicates whether an object has a specified property defined. | Object | ||
Decompresses the byte array using the deflate compression algorithm. | ByteArray | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Reads a Boolean value from the byte stream. | ByteArray | ||
Reads a signed byte from the byte stream. | ByteArray | ||
Reads the number of data bytes, specified by the length parameter, from the byte stream. | ByteArray | ||
Reads an IEEE 754 double-precision (64-bit) floating-point number from the byte stream. | ByteArray | ||
Reads an IEEE 754 single-precision (32-bit) floating-point number from the byte stream. | ByteArray | ||
Reads a signed 32-bit integer from the byte stream. | ByteArray | ||
Reads a multibyte string of specified length from the byte stream using the
specified character set. | ByteArray | ||
readObject():*
Reads an object from the byte array, encoded in AMF
serialized format. | ByteArray | ||
Reads a signed 16-bit integer from the byte stream. | ByteArray | ||
Reads an unsigned byte from the byte stream. | ByteArray | ||
Reads an unsigned 32-bit integer from the byte stream. | ByteArray | ||
Reads an unsigned 16-bit integer from the byte stream. | ByteArray | ||
Reads a UTF-8 string from the byte stream. | ByteArray | ||
Reads a sequence of UTF-8 bytes specified by the length
parameter from the byte stream and returns a string. | ByteArray | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Provides an overridable method for customizing the JSON encoding of values in an ByteArray object. | ByteArray | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Converts the byte array to a string. | ByteArray | ||
Decompresses the byte array. | ByteArray | ||
Returns the primitive value of the specified object. | Object | ||
Writes a Boolean value. | ByteArray | ||
Writes a byte to the byte stream. | ByteArray | ||
Writes a sequence of length bytes from the
specified byte array, bytes,
starting offset(zero-based index) bytes
into the byte stream. | ByteArray | ||
Writes an IEEE 754 double-precision (64-bit) floating-point number to the byte stream. | ByteArray | ||
Writes an IEEE 754 single-precision (32-bit) floating-point number to the byte stream. | ByteArray | ||
Writes a 32-bit signed integer to the byte stream. | ByteArray | ||
Writes a multibyte string to the byte stream using the specified character set. | ByteArray | ||
Writes an object into the byte array in AMF
serialized format. | ByteArray | ||
Writes a 16-bit integer to the byte stream. | ByteArray | ||
Writes a 32-bit unsigned integer to the byte stream. | ByteArray | ||
Writes a UTF-8 string to the byte stream. | ByteArray | ||
Writes a UTF-8 string to the byte stream. | ByteArray |
ByteArrayAsset | () | Constructor |
public function ByteArrayAsset()
Language Version: | ActionScript 3.0 |
Product Version: | Flex 3 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
Constructor.
Thu Dec 6 2018, 01:12 PM -08:00