blob: 834e4d94d51ae53a56e66794ac537526e3b6c4b3 [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package mx.core
{
import flash.utils.ByteArray;
/**
* ByteArrayAsset is a subclass of the flash.utils.ByteArray class
* which represents an arbitrary sequence of byte data that you embed
* in a Flex application.
*
* <p>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.</p>
*
* <p>The MXML compiler autogenerates a class that extends ByteArrayAsset
* to represent the embedded data.</p>
*
* <p>To embed an arbitrary file, you declare a variable of type Class,
* and put <code>[Embed]</code> metadata on it, using the MIME type
* <code>application/octet-stream</code>.
* For example, you embed a text file like this:</p>
*
* <pre>
* [Bindable]
* [Embed(source="Story.txt", mimeType="application/octet-stream")]
* private var storyClass:Class;
* </pre>
*
* <p>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 <code>new</code> operator, and you can extract
* information from the byte array using methods of the ByteArray class:</p>
*
* <pre>
* var storyByteArray:ByteArrayAsset = ByteArrayAsset(new storyClass());
* var story:String = storyByteArray.readUTFBytes(storyByteArray.length);
* </pre>
*
* <p>You must specify that the MIME type for the embedding is
* <code>application/octet-stream</code>, 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.</p>
*
* <p>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 <code>application/octet-stream</code>,
* then no transcoding will occur, the PNG data will be embedded
* as is, and the autogenerated class will extend ByteArrayAsset.</p>
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public class ByteArrayAsset extends ByteArray implements IFlexAsset
{
include "../core/Version.as";
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
/**
* Constructor.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function ByteArrayAsset()
{
super();
}
}
}