com.flagstone.transform
Class MovieHeader

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

public final class MovieHeader
extends Object
implements MovieTag

MovieHeader contains the attributes that make up the header fields of a Flash file. Previously these were attributes of the Movie class.


Constructor Summary
MovieHeader()
          Construct a new MovieHeader with Flash version and compression set to the values supported in this version of Transform SWF.
MovieHeader(MovieHeader object)
          Creates and initialises a MovieAttributes object using the values copied from another MovieAttributes object.
MovieHeader(SWFDecoder coder, Context context)
          Creates and initialises a MovieAttributes object using values encoded in the Flash binary format.
 
Method Summary
 MovieHeader copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 int getFrameCount()
          Get the number of frames in the movie.
 float getFrameRate()
          Get the number of frames played per second that the movie will be displayed at.
 Bounds getFrameSize()
          Get the bounding rectangle that defines the size of the player screen.
 int getVersion()
          Get the number representing the version of Flash that the movie represents.
 boolean isCompressed()
          Is the movie compressed.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setCompressed(boolean compress)
          Set whether the movie should be compressed when encoded.
 void setFrameCount(int count)
          Set the number of frames in the movie.
 void setFrameRate(float rate)
          Sets the number of frames played per second that the Player will display the coder.
 void setFrameSize(Bounds rect)
          Sets the bounding rectangle that defines the size of the player screen.
 void setVersion(int aNumber)
          Sets the Flash version supported in this Movie.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MovieHeader

public MovieHeader(SWFDecoder coder,
                   Context context)
            throws IOException
Creates and initialises a MovieAttributes object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
context - a Context object used to manage the decoders for different type of object and to pass information on how objects are decoded.
Throws:
IOException - if an error occurs while decoding the data.

MovieHeader

public MovieHeader()
Construct a new MovieHeader with Flash version and compression set to the values supported in this version of Transform SWF.


MovieHeader

public MovieHeader(MovieHeader object)
Creates and initialises a MovieAttributes object using the values copied from another MovieAttributes object.

Parameters:
object - a MovieAttributes object from which the values will be copied.
Method Detail

getVersion

public int getVersion()
Get the number representing the version of Flash that the movie represents.

Returns:
the version number of Flash that this movie contains.

setVersion

public void setVersion(int aNumber)
Sets the Flash version supported in this Movie. Note that there are no restrictions on the objects that can be used in a coder. Using objects that are not supported by an earlier version of the Flash file format may cause the Player to not display the movie correctly or even crash the Player.

Parameters:
aNumber - the version of the Flash file format that this movie utilises.

getFrameSize

public Bounds getFrameSize()
Get the bounding rectangle that defines the size of the player screen.

Returns:
the bounding box that defines the screen.

setFrameSize

public void setFrameSize(Bounds rect)
Sets the bounding rectangle that defines the size of the player screen. The coordinates of the bounding rectangle are also used to define the coordinate range. For example if a 400 x 400 pixel rectangle is defined, specifying the values for the x and y coordinates the range -200 to 200 sets the centre of the screen at (0,0), if the x and y coordinates are specified in the range 0 to 400 then the centre of the screen will be at (200, 200).

Parameters:
rect - the Bounds object that defines the frame size. Must not be null.

getFrameRate

public float getFrameRate()
Get the number of frames played per second that the movie will be displayed at.

Returns:
the movie frame rate.

setFrameRate

public void setFrameRate(float rate)
Sets the number of frames played per second that the Player will display the coder.

Parameters:
rate - the number of frames per second that the movie is played.

getFrameCount

public int getFrameCount()
Get the number of frames in the movie. The value returned is only valid for movies that have just been decoded or encoded. The number returned will not be valid if the movie was edited.

Returns:
the number of frames.

setFrameCount

public void setFrameCount(int count)
Set the number of frames in the movie. This method is not usually called since the number of frames will be set automatically when the movie is encoded.

Parameters:
count - the number of frames in the movie.

isCompressed

public boolean isCompressed()
Is the movie compressed.

Returns:
true if the movie contains zlib compressed data or false if it is not compressed.

setCompressed

public void setCompressed(boolean compress)
Set whether the movie should be compressed when encoded.

Parameters:
compress - true if the movie will be compressed, false if no compression will be applied.

copy

public MovieHeader 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.