com.flagstone.transform
Class DefineData

java.lang.Object
  extended by com.flagstone.transform.DefineData
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, DefineTag, MovieTag

public final class DefineData
extends Object
implements DefineTag

DefineData is used to embed binary data in a Flash file.

DefineData can also be used to initialize Actionscript3 classes when they are loaded into the Flash Player. The table in a SymbolClass object maps class names to object definitions in the movie using a unique identifier. If the class is a sub-class of ByteArray then the data from the DefineData object with a matching identifier will be used to initialize the class.

See Also:
SymbolClass

Constructor Summary
DefineData(DefineData object)
          Creates a DefineData initialize with a copy of the data from another object.
DefineData(int uid, byte[] bytes)
          Creates a DefineData object with the specified data.
DefineData(SWFDecoder coder)
          Creates and initialises a DefineData object using values encoded in the Flash binary format.
 
Method Summary
 DefineData copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 byte[] getData()
          Get the array of bytes that will be embedded in the Flash file.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setData(byte[] bytes)
          Sets the array of bytes that will be embedded in the Flash file.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineData

public DefineData(SWFDecoder coder)
           throws IOException
Creates and initialises a DefineData object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

DefineData

public DefineData(int uid,
                  byte[] bytes)
Creates a DefineData object with the specified data.

Parameters:
uid - the unique identifier used to reference this object.
bytes - the data to initialize the object.

DefineData

public DefineData(DefineData object)
Creates a DefineData initialize with a copy of the data from another object.

Parameters:
object - a DefineData object used to initialize this one.
Method Detail

getIdentifier

public int getIdentifier()
Get the unique identifier assigned to this object.

Specified by:
getIdentifier in interface DefineTag
Returns:
the unique identifier used by the Flash Player to reference this definition.

setIdentifier

public void setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - a unique identifier for the object. Must be in the range 1..65535.

getData

public byte[] getData()
Get the array of bytes that will be embedded in the Flash file.

Returns:
a copy of the data.

setData

public void setData(byte[] bytes)
Sets the array of bytes that will be embedded in the Flash file.

Parameters:
bytes - a list of bytes that contain the encoded binary data. Must not be null.

copy

public DefineData copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<MovieTag>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()

Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.