|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSMovieObject
com.flagstone.transform.FSPlaceObject
public class FSPlaceObject
FSPlaceObject is used to add an object (shape, button, etc.) to the Flash Player's display list.
Attributes | |
---|---|
type | Identifies the data structure when it is encoded. Read-only. |
identifier | The unique identifier, in the range 1..65535, of the object to be displayed. |
layer | The Display List layer on which the object is drawn. |
coordTransform | An FSCoordTransform which defines the location and appearance of the object. |
colorTransform | An FSColorTransform which defines any changes to be made to the object's original colour. Optional. May be set to null if an object's colour is not being changed. |
Every class that defines a shape, button etc. is assigned a unique identifier. This is an integer in the range 1..65535 and is used to refer to objects when performing actions such as adding or removing them from the display list.
The display list contains all the objects that are currently visible on the Flash Player's screen. The display list is ordered in layers, with one (and only one) object displayed on each layer. The Layer defines the order in which objects are displayed. Objects with a higher layer number are displayed in front of objects on a lower layer.
The coordinate transform is principally used to specify the location of the object when it is drawn on the screen however more complex coordinate transforms can also be specified such as rotating or scaling the object without changing the original definition.
Similarly the color transform allows the color of the object to be changed when it is displayed without changing the original definition. The FSPlaceObject class only supports opaque colours so although the FSColorTransform supports transparent colours this information is ignored by the Flash Player. The colour transform is optional and may be set to the null object.
The following simplified code fragments illustrate how the FSPlaceObject class can be used.
1. Display an object.
Display an object on layer 1 at (400, 400).
FSPlaceObject provides a constructor which specifies just the x and y
coordinates, the FSCoordTransform object is constructed internally.
FSDefineShape shape = new FSDefineShape(movie.newIdentifier(), ......) movie.add(new FSPlaceObject(shape.getIdentifier(), 1, 400, 400)); movie.add(new FSShowFrame());
2. Scale an object.
Scale an object to twice its original size by
specifying a more complex coordinate transformation. Complex transforms can
be created by compositing individual steps.
FSCoordTransform location = FSCoordTransform.translate(200, 200); FSCoordTransform scale = FSCoordTransform.scale(2.0, 2.0); FSCoordTransform transform = FSCoordTransform.composite(location, scale); movie.add(new FSPlaceObject(shape.getIdentifier(), 1, transform)); movie.add(new FSShowFrame());
3. Move an object.
To move an object the FSPlaceObject class must be
used in conjunction with the FSRemoveObject class to first remove the object
from its existing position before being placed at the new location.
// Add the shape to the display list. movie.add(new FSPlaceObject(shape.getIdentifier(), 1, 400, 400)); movie.add(new FSShowFrame()); // Move shape to a new location, removing the original so it does not get displayed twice. movie.add(new FSRemoveObject(shape.getIdentifier(), 1)); movie.add(new FSPlaceObject(shape.getIdentifier(), 1, 250, 300)); movie.add(new FSShowFrame());
The FSPlaceObject class represents the PlaceObject tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1 and is superseded by the PlaceObject2 tag which was added in Flash 3.
Field Summary |
---|
Constructor Summary | |
---|---|
FSPlaceObject(FSCoder coder)
Construct an FSPlaceObject object, initalising it with values decoded from an encoded object. |
|
FSPlaceObject(FSPlaceObject obj)
Constructs an FSPlaceObject object by copying values from an existing object. |
|
FSPlaceObject(int anIdentifier,
int aLayer,
FSCoordTransform aTransform)
Constructs an FSPlaceObject object that places the object with the identifier at the specified layer with the coordinate transform. |
|
FSPlaceObject(int anIdentifier,
int aLayer,
FSCoordTransform aTransform,
FSColorTransform aColorTransform)
Constructs an FSPlaceObject object that places the the object with the identifier at the specified layer, coordinate transform and colour transform. |
|
FSPlaceObject(int anIdentifier,
int aLayer,
int xLocation,
int yLocation)
Constructs an FSPlaceObject object that places an object with the identifier into the display list layer at the specified coordinates (x,y). |
Method Summary | |
---|---|
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 object. |
void |
decode(FSCoder coder)
|
void |
encode(FSCoder coder)
|
boolean |
equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. |
FSColorTransform |
getColorTransform()
Gets the colour transform that defines any colour effects applied when the object is displayed. |
int |
getIdentifier()
Gets the identifier of the object. |
int |
getLayer()
Gets the layer that defines the order in which objects are displayed. |
FSCoordTransform |
getTransform()
Gets the transform that defines the position where the object is displayed. |
int |
length(FSCoder coder)
|
void |
setColorTransform(FSColorTransform aColorTransform)
Sets the colour transform that defines any colour effects applied when the object is displayed. |
void |
setIdentifier(int anIdentifier)
Sets the identifier of the object. |
void |
setLayer(int aNumber)
Sets the layer that defines the order in which objects are displayed. |
void |
setTransform(FSCoordTransform aTransform)
Sets the transform that defines the position where the object is displayed. |
Methods inherited from class com.flagstone.transform.FSMovieObject |
---|
getType |
Methods inherited from class com.flagstone.transform.FSTransformObject |
---|
name, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FSPlaceObject(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSPlaceObject(int anIdentifier, int aLayer, int xLocation, int yLocation)
anIdentifier
- the unique identifier for the object to the placed on the
display list.aLayer
- the layer in the display list where the object will be placed.xLocation
- the x-coordinate where the object will be drawn.yLocation
- the y-coordinate where the object will be drawn.public FSPlaceObject(int anIdentifier, int aLayer, FSCoordTransform aTransform)
anIdentifier
- the unique identifier for the object to the placed on the
display list.aLayer
- the layer in the display list where the object will be placed.aTransform
- an FSCoordTransform object that defines the orientation, size
and location of the object when it is drawn.public FSPlaceObject(int anIdentifier, int aLayer, FSCoordTransform aTransform, FSColorTransform aColorTransform)
anIdentifier
- the unique identifier for the object to the placed on the
display list.aLayer
- the layer in the display list where the object will be placed.aTransform
- an FSCoordTransform object that defines the orientation, size
and location of the object when it is drawn.aColorTransform
- an FSColorTransform object that defines the colour of the
object when it is drawn.public FSPlaceObject(FSPlaceObject obj)
obj
- an FSPlaceObject object.Method Detail |
---|
public int getIdentifier()
public int getLayer()
public FSCoordTransform getTransform()
public FSColorTransform getColorTransform()
public void setIdentifier(int anIdentifier)
anIdentifier
- the unique identifier for the object to the placed on the
display list.public void setLayer(int aNumber)
aNumber
- the layer in the display list where the object will be placed.public void setTransform(FSCoordTransform aTransform)
aTransform
- an FSCoordTransform object that defines the orientation, size
and location of the object when it is drawn.public void setColorTransform(FSColorTransform aColorTransform)
aColorTransform
- an FSColorTransform object that defines the colour of the
object when it is drawn.public java.lang.Object clone()
FSTransformObject
clone
in class FSTransformObject
public boolean equals(java.lang.Object anObject)
FSMovieObject
equals
in class FSMovieObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSMovieObject
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.public int length(FSCoder coder)
length
in class FSMovieObject
public void encode(FSCoder coder)
encode
in class FSMovieObject
public void decode(FSCoder coder)
decode
in class FSMovieObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |