|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSMovie
public class FSMovie
FSMovie is a container class for the objects that represents the data structures in a Flash file. FSMovie is the core class of the Transform package. It is used to parse and generate Flash files, translating the binary format of the Flash file into an array objects that can be inspected and updated. An FSMovie object also contains the attributes that make up the header information of the Flash file, identifying the version support, size of the Flash Player screen, etc.:
Attributes | |
---|---|
signature | The signature is a three character code that identifies that the file contains Flash encoded data. For Flash versions 1 to 5 this was 'F', 'W', 'S' ("SWF" reversed). In Flash 6, zlib compressed files were introduced to reduce file sizes. Compressed files are identified by the signature, 'C', 'W', 'S'. |
version | The version of Flash that is contained in the file. |
frameSize | An FSBounds object that define the size of the Flash Player's screen when playing the movie. |
frameRate | The number of frames per second that the movie will be played at. |
objects | An array of FSMovieObjects that define the shapes, buttons, images etc to be displayed along with the commands that control how the movie is animated. |
FSMovie movie = new FSMovie(); // Define a shape to be displayed FSDefineShape rectangle = new FSDefineShape(movie.newIdentifier(), ....); // Set the size of the Flash Player screen 400x400 and the number of // frames displayed per second. movie.setFrameSize(new FSBounds(0, 0, 400, 400)); movie.setFrameRate(1.0); // Set the background colour for the movie movie.add(new FSSetBackgroundColor(FSColor.lightblue())); // Add the shape to the movie. All objects must be defined before // they can be used. movie.add(rectangle); // Place the shape in the centre of the screen (200,200) on the first layer // in the Flash Player's display list. movie.add(new FSPlaceObject2(FSPlaceObject2.New, rectangle.getIdentifier(), 1, 200, 200)); // Display the frame movie.add(new FSShowFrame());Note that when the shape was defined a call was made to the newIdentifier() method on the movie. Each object that defines either a shape, button, sound etc., is assigned a unique identifier to allow the object to be referenced in objects such as FSPlaceObject which places the shape on the Flash Player's display list. The identifier is unique only within a movie so the FSMovie class maintains a counter that is used to generate values for the identifiers that are assigned to objects derived from the Definition class. To generate a Flash file use the
encodeToFile(String fileName)
method:
try { aMovie.encodeToFile(filename); } catch (Exception e) { ... Process Exception ... }
FSMovie(String fileName)
constructor:
FSMovie aMovie = null; String fileName = "aFlashFile.swf"; try { aMovie = new FSMovie(filename); } catch (Exception e) { ... Process Exception ... }The objects array of the movie will contain an instance of the respective package class for each data structure decoded from the file. The objects may be inspected and their attributes changed accordingly. The FSMovie object keeps track of the identifiers assigned to objects that define the shapes, buttons, sounds etc. that make up a Flash file. If a new object is added to the movie then the call to newIdentifier() is guaranteed to return a value that is unique within the movie. Multiple Language Support
Constructor Summary | |
---|---|
FSMovie()
Constructs an FSMovie object with no objects. |
|
FSMovie(byte[] data)
Constructs an FSMovie object and decodes the binary data presented in the byte array to generate an array of objects representing the Flash data. |
|
FSMovie(byte[] data,
FSMovieListener listener)
Deprecated. using the constructor FSMovie(byte[]) which throws an exception if an error is detected. |
|
FSMovie(FSBounds aBounds,
float framesPerSecond)
Constructs an FSMovie object with the specified bounding rectangle, frame rate and no objects. |
|
FSMovie(java.lang.String fileName)
Constructs an FSMovie object and decodes the contents of the specified file to generate an array of objects representing the Flash file. |
|
FSMovie(java.lang.String fileName,
FSMovieListener listener)
Deprecated. |
|
FSMovie(java.lang.String encoding,
java.lang.String signature,
int version,
FSBounds aBounds,
float framesPerSecond,
java.util.ArrayList anArray)
Constructs an FSMovie object with the specified signature, version, bounding rectangle, frame rate and array of objects. |
Method Summary | |
---|---|
void |
add(java.util.ArrayList array)
Adds all of the objects in the array to the Movie. |
void |
add(FSMovieObject anObject)
Adds the object to the Movie. |
void |
appendDescription(java.lang.StringBuffer buffer,
int depth)
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. |
java.lang.Object |
clone()
Creates a deep copy of the entire movie. |
void |
decodeFromData(byte[] bytes)
Decodes the binary Flash data stored in the byte array. |
void |
decodeFromData(byte[] bytes,
FSMovieListener listener)
Deprecated. use the decodeFromData(bytep[]) method which throws an exception if an error is detected. |
void |
decodeFromFile(java.lang.String fileName)
Decodes the contents of the specified file. |
void |
decodeFromFile(java.lang.String fileName,
FSMovieListener listener)
Deprecated. use the decodeFromFile(String) method which throws an exception if an error is detected. |
byte[] |
encode()
Returns the encoded representation of the array of objects that this Movie contains. |
byte[] |
encode(FSMovieListener listener)
Deprecated. use the encode() method which throws an exception if an error is detected. |
void |
encodeToFile(java.lang.String fileName)
Encodes the array of objects and writes the data to the specified file. |
void |
encodeToFile(java.lang.String fileName,
FSMovieListener listener)
Deprecated. use the encodeToFile(String) method which throws an exception if an error is detected. |
boolean |
equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. |
java.lang.String |
getEncoding()
Gets the encoding scheme for strings encoded and decoded from Flash files. |
float |
getFrameRate()
Gets the number of frames played per second that the movie will be displayed at. |
FSBounds |
getFrameSize()
Gets the bounding rectangle that defines the size of the player screen. |
int |
getIdentifier()
Gets the current value for the unique identifier that will be assigned to definition objects (classes derived from the FSDefineObject class). |
java.util.ArrayList |
getObjects()
Gets the array of objects contained in the Movie. |
java.util.ArrayList |
getObjectsOfType(int aType)
Gets an array of objects from the Movie with the specified type. |
java.lang.String |
getSignature()
Gets the signature identifying that the movie contains Flash. |
int |
getVersion()
Gets the number representing the version of Flash that the movie represents. |
int |
newIdentifier()
Returns a unique identifier for an object derived from the FSDefineObject class. |
void |
setDecodeActions(boolean decode)
|
void |
setDecodeGlyphs(boolean decode)
|
void |
setDecodeShapes(boolean decode)
|
void |
setEncoding(java.lang.String encoding)
Sets the encoding scheme for strings encoded and decoded from Flash files. |
void |
setFrameRate(float aNumber)
Sets the number of frames played per second that the Player will display the coder. |
void |
setFrameSize(FSBounds aBounds)
Sets the bounding rectangle that defines the size of the player screen. |
void |
setIdentifier(int aValue)
Sets the initial value for the unique identifier assigned to definition objects. |
void |
setObjects(java.util.ArrayList anArray)
Sets the array of objects contained in the Movie. |
void |
setSignature(java.lang.String aString)
Sets the signature for the Flash data when it is encoded. |
void |
setVersion(int aNumber)
Sets the Flash version supported in this Movie. |
boolean |
willDecodeActions()
|
boolean |
willDecodeGlyphs()
|
boolean |
willDecodeShapes()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FSMovie()
public FSMovie(FSBounds aBounds, float framesPerSecond)
aBounds
- the bounding rectangle that defines the size of each frame in
the coder.framesPerSecond
- the number of frames per second that the Player plays the
movie at.public FSMovie(java.lang.String encoding, java.lang.String signature, int version, FSBounds aBounds, float framesPerSecond, java.util.ArrayList anArray)
encoding
- the format used to encode or decode strings.signature
- a string indicating that the file contains Flash data, either
"FWS" for uncompressed files or "CWS" for compressed files.version
- the version number of Flash implemented in this coder.aBounds
- the bounding rectangle that defines the size of each frame in
the coder.framesPerSecond
- the number of frames per second that the Player plays the
movie at.anArray
- the array of objects that define the coder.public FSMovie(java.lang.String fileName) throws java.io.IOException, java.util.zip.DataFormatException
fileName
- the path to the Flash file that will be parsed.
java.io.FileNotFoundException
- -
if an error occurs while reading the file.
java.util.zip.DataFormatException
- -
if the file does not contain Flash data.
FSCoderException
- -
if an error occurs while decoding the file.
java.io.IOException
- -
if an I/O error occurs while reading the file.public FSMovie(java.lang.String fileName, FSMovieListener listener)
fileName
- the path to the Flash file that will be parsed.listener
- an FSMovieListener object where errors messages are sent.public FSMovie(byte[] data) throws java.util.zip.DataFormatException, java.io.IOException
data
- an array of bytes containing the Flash binary data.
java.util.zip.DataFormatException
- -
if the file does not contain Flash data.
FSCoderException
- -
if an error occurs while decoding the file.
java.io.IOException
- -
if an I/O error occurs while reading the file.public FSMovie(byte[] data, FSMovieListener listener)
data
- an array of bytes containing the Flash binary data.listener
- an FSMovieListener object where errors messages are sent.Method Detail |
---|
public int newIdentifier()
public int getIdentifier()
public void setIdentifier(int aValue)
aValue
- the initial value for the unique identifier.public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
encoding
- string identifying the format for strings. Any string
recognised by the Java environment may be used, "ASCII",
"SJIS" and UTF8" will be the three most commonly used.public void setDecodeActions(boolean decode)
public boolean willDecodeActions()
public void setDecodeShapes(boolean decode)
public boolean willDecodeShapes()
public void setDecodeGlyphs(boolean decode)
public boolean willDecodeGlyphs()
public java.lang.String getSignature()
public void setSignature(java.lang.String aString)
aString
- the signature used for the encoded Flash file.public int getVersion()
public void setVersion(int aNumber)
aNumber
- the version of the Flash file format that this movie utilises.public FSBounds getFrameSize()
public void setFrameSize(FSBounds aBounds)
aBounds
- the FSBounds object that defines the frame size.public float getFrameRate()
public void setFrameRate(float aNumber)
aNumber
- the number of frames per second that the movie is played.public java.util.ArrayList getObjects()
public void setObjects(java.util.ArrayList anArray)
anArray
- the array of objects that describe a coder.public void add(FSMovieObject anObject)
anObject
- the object to be added to the movie.public void add(java.util.ArrayList array)
array
- an array of FSMovieObjects.public java.util.ArrayList getObjectsOfType(int aType)
ArrayList allShapes = aMovie.getObjectsOfType(FSMovieObject.DefineShape);Note that only objects at the "top-level" in the movie are checked, namely movie or definition objects. Objects "owned" by another object such as Action objects inside FSDoAction, FSButtonEvent or FSClipEvent objects cannot be retrieved using this method.
aType
- the type to search the movie for.public void decodeFromFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.util.zip.DataFormatException, java.io.IOException
fileName
- the path to the Flash file that will be parsed.
java.io.FileNotFoundException
- -
if an error occurs while reading the file.
java.util.zip.DataFormatException
- -
if the file does not contain Flash data.
FSCoderException
- -
if an error occurs while decoding the file.
java.io.IOException
- -
if an I/O error occurs while reading the file.public void decodeFromFile(java.lang.String fileName, FSMovieListener listener)
fileName
- the path to the Flash file that will be parsed.listener
- an FSMovieListener object where errors messages are sent.public void decodeFromData(byte[] bytes) throws java.util.zip.DataFormatException, java.io.IOException
bytes
- an array of bytes that contain the encoded Flash objects.
java.util.zip.DataFormatException
- -
if the file does not contain Flash data.
FSCoderException
- -
if an error occurs while decoding the file.
java.io.IOException
- -
if an I/O error occurs while reading the file.public void decodeFromData(byte[] bytes, FSMovieListener listener)
bytes
- an array of bytes that contain the encoded Flash objects.listener
- an FSMovieListener object where errors messages are sent.public void encodeToFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
fileName
- the path to the Flash file that the movie will be encoded to.
java.io.FileNotFoundException
- -
if an error occurs while opening the file.
FSCoderException
- -
if an error occurs while encoding the file.
java.io.IOException
- -
if an I/O error occurs while writing the file.public void encodeToFile(java.lang.String fileName, FSMovieListener listener)
fileName
- the path to the Flash file that the movie will be encoded to.listener
- an FSMovieListener object where errors messages are sent.public byte[] encode() throws java.io.IOException
FSCoderException
- -
if an error occurs while encoding the file.
java.io.IOException
- -
if an I/O error occurs while encoding the file.public byte[] encode(FSMovieListener listener)
listener
- an FSMovieListener object where errors messages are sent.
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object anObject)
equals
in class java.lang.Object
public void appendDescription(java.lang.StringBuffer buffer, int depth)
buffer
- a StringBuffer to which the description of each object is
appended.depth
- the maximum level of nesting up to which objects will be
displayed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |