|
|||||||||
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.FSPlaceObject2
public class FSPlaceObject2
FSPlaceObject2 is used to add and manipulate objects (shape, button, etc.) on the Flash Player's display list.
FSPlaceObject2 supersedes the FSPlaceObject class providing more functionality and easier manipulation of objects in the display list through the following operations:
Clipping Depth
With the introduction of Flash 3 the display
list supported a clipping layer. This allowed the outline of an object to
define a clipping path that is used to mask other objects placed in front of
it. The clipping depth can be set to mask objects between the layer
containing the clipping path and a specified layer.
Shape Morphing
Shapes that will be morphed are defined using
the FSDefineMorphShape class which defines a start and end shape. The Flash
Player performs the interpolation that transforms one shape into another. The
progress of the morphing process is controlled by a ratio which ranges from
0.0 to 1.0, where 0 generates a shape identical to the starting shape in the
FSDefineMorphShape object and 1.0 generates the shape at the end of the
morphing process.
Movie Clip Events
With the introduction of Flash 5, movie
clips (defined using the FSDefineMovieClip class) could specify sequences of
actions that would be performed in response to mouse or keyboard events. The
actions are specified using FSClipEvent objects and the FSPlaceObject2 class
is used to register the actions in response to a particular event with the
Flash player. Multiple events can be handled by defining an FSClipEvent for
each type of event. For more information see the FSClipEvent class.
Attributes | |
---|---|
type | Identifies the data structure when it is encoded. Read-only. |
place | Indicates whether a new object is being placed in the display list or an existing object is being modified or replaced. |
identifier | The identifier of the object to added to the display list. |
layer | Defines the order in which objects are displayed. |
transform | Optional. A coordinate transform defines the position, scale and rotation of the object. |
colorTransform | Optional. A colour transform defines any colour changes such as transparency effects. |
depth | Optional. The layer number up to which objects will be clipped by this object's outline. |
ratio | Optional. The point for the morphing process of a shape. |
name | Optional. A name to assign to the object. |
events | Optional. An array of FSClipEvent objects that define the actions that are performed when a specific movie clip event occurs. |
encodedEvents | An array of bytes containing encoded clip events can also be set. The encoded objects are typically generated by the parser in the Translate framework. The events array and encodedEvents cannot both be valid at the same time. Accessor methods used to set either of the attributes will set the other to null. |
Since only one object can be placed on a given layer an existing object on the display list can be identified by the layer it is displayed on rather than its identifier. Therefore Layer is the only required attribute. The remaining attributes are optional according to the different operation being performed:
The class provides a range of constructors which define different subsets of the attributes according to the type of operation that will be performed on an object in the Flash Player's display list. If an attribute is not specified in a constructor then it will be assigned a default value and will be omitted when the object is encoded.
The following code samples illustrate how to use the FSPlaceObject2 class to manipulate objects on the display list. These examples use constructors with the most convenient (simplest) arguments. To define more complex place operations constructors are provided that take larger numbers of arguments and allow more complex transformations to be specified.
1. Display an object.
To display an object at a given location the
placeType, identifier, layer number and x,y coordinates are required.
// Add the shape to the display list - on layer 1 at coordinates (400, 400) // The constructor allows just the x and y coordinate to be defined, the // FSCoordTransform object is constructed internally. FSDefineShape shape = new FSDefineShape(movie.newIdentifier(), ......); movie.add(new FSPlaceObject2(shape.getIdentifier(), 1, 400, 400)); movie.add(new FSShowFrame());
2. Move an object.
To move an object only the layer number is required.
This simplifies the code required to manipulate existing objects when
compared to the original FSPlaceObject class.
// Add the shape to the display list. movie.add(new FSPlaceObject2(shape.getIdentifier(), 1, 400, 400)); movie.add(new FSShowFrame()); // Move shape to a new location. movie.add(new FSPlaceObject2(1, 250, 300)); movie.add(new FSShowFrame());
3. Replace an existing object with another.
To move an object only the
layer number is required. This simplifies the code required to manipulate
existing objects when compared to the original FSPlaceObject class.
// Add the shape to the display list. movie.add(new FSPlaceObject2(shape.getIdentifier(), 1, 400, 400)); movie.add(new FSShowFrame()); // Replace the shape. movie.add(new FSPlaceObject2(newShape.getIdentifier(), 1)); movie.add(new FSShowFrame());
4. Defining a clipping layer.
The number of layers to clip using the
outline of the shape as a path can be specified when placing the shape on the
display list.
// Add the shape to the display list and clip objects on the next two layers currentLayer = 1; clipTo = currentLayer + 2; movie.add(new FSPlaceObject2(shape.getIdentifier(), currentLayer, clipTo, 400, 400)); movie.add(new FSShowFrame());
5. Controlling the morphing process.
The ratio attribute controls the
progress as an FSDefineMorphShape object changes from one shape into another.
FSShape triangle = new FSShape(....); FSShape hexagon = new FSShape(....); FSDefineMorphShape shape = new FSDefineMorphShape(movie.newIdentifier(), ...., triangle, hexagon); movie.add(new FSPlaceObject2(shape.getIdentifier(), 1, 0.0, 400, 400)); // Morph the shapes over 10 frames for (float i=0.1; i<1.0; i+= 0.1) { movie.add(new FSPlaceObject(1, i)); movie.add(new FSShowFrame()); }
6. Defining a movie clip event.
FSClipEvent objects are ONLY used to
define the sequence of actions executed when a particular event occurs in a
movie clip.
// Define an array of clip events that will contain one event that defines the // behaviour of the movie clip in response to a mouse down event. ArrayList events = new ArrayList(); FSClipEvent clipEvent = new FSClipEvent(FSClipEvent.MouseDown); // Add one or more actions for the mouse down event. clipEvent.add(...); ... // Add the clip event to the array of events for the movie clip. events.add(clipEvent); // Create the commands to animate the movie clip. ArrayList commands = new ArrayList(); commands.add(...); FSDefineMovieClip movieClip = new FSDefineMovieClip(movie.newIdentifier(), commands); // Now place the movie clip on the screen on layer 1 at (400, 400). movie.add(new FSPlaceObject2(movieClip.getIdentifier(), 1, events, 400, 400));
The FSPlaceObject2 class represents the PlaceObject2 tag from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 3.
Field Summary | |
---|---|
static int |
Modify
|
static int |
New
|
static int |
Replace
|
Constructor Summary | |
---|---|
FSPlaceObject2(FSCoder coder)
Construct an FSPlaceObject2 object, initialising it with values decoded from an encoded object. |
|
FSPlaceObject2(FSPlaceObject2 obj)
Constructs an FSPlaceObject2 object by copying values from an existing object. |
|
FSPlaceObject2(int aLayer,
float aRatio,
FSCoordTransform transform)
Constructs an FSPlaceObject2 object that modifies the morphing shape located on layer, aLayer in the display list. |
|
FSPlaceObject2(int aLayer,
float aRatio,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object that changes the location of the object in the display list at layer, aLayer to the coordinates (x,y). |
|
FSPlaceObject2(int aLayer,
FSColorTransform colorTransform)
Constructs an FSPlaceObject2 object that applied the specified colour transform to the object in the display list at layer, aLayer. |
|
FSPlaceObject2(int aLayer,
FSCoordTransform transform)
Constructs an FSPlaceObject2 object that applies the specified coordinate transform to the object in the display list at layer, aLayer. |
|
FSPlaceObject2(int aLayer,
FSCoordTransform transform,
FSColorTransform colorTransform)
Constructs an FSPlaceObject2 object that applies the specified coordinate and colour transforms to the object in the display list at layer, aLayer. |
|
FSPlaceObject2(int anIdentifier,
int aLayer)
Constructs an FSPlaceObject2 object that replaces the object at the specified layer in the display list, aLayer with the object with the identifier, anIdentifier. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
java.util.ArrayList anArray,
java.lang.String aName,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object that places a new, named movie clip on the display list at the coordinates on the screen. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
byte[] bytes,
java.lang.String aName,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object that places a new, named movie clip on the display list at the coordinates on the screen. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
float aRatio,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object to place new morphing shape on the display list at the coordinates on the screen. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
FSCoordTransform aTransform)
Constructs an FSPlaceObject2 object to place a new shape on the display list with the specified coordinate and optional colour transform. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
FSCoordTransform aTransform,
FSColorTransform aColorTransform)
Constructs an FSPlaceObject2 object to place a new shape on the display list with the specified coordinate and optional colour transform. |
|
FSPlaceObject2(int aLayer,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object that changes the location of the object in the display list at layer, aLayer to the coordinates (x,y). |
|
FSPlaceObject2(int aPlace,
int anIdentifier,
int aLayer,
FSCoordTransform transform,
FSColorTransform colorTransform)
Constructs an FSPlaceObject2 object with the specified placement type, object identifier, layer number, coordinate transform and colour transform. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object to place a new object on the display list at the coordinates on the screen. |
|
FSPlaceObject2(int anIdentifier,
int aLayer,
int aDepth,
int xLocation,
int yLocation)
Constructs an FSPlaceObject2 object to place a new shape on the display list at the coordinates on the screen that defines a clipping path that will clip objects for the specified number of layers. |
Method Summary | |
---|---|
void |
add(FSClipEvent aClipEvent)
Adds a clip event to the array of clip events. |
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. |
java.util.ArrayList |
getClipEvents()
Gets the array of FSClipEvent object that define the actions that will be executed in response to events that occur in the FSDefineMovieClip being placed. |
int |
getClippingDepth()
Gets the number of layers that will be clipped by the object placed on the layer specified in this object. |
FSColorTransform |
getColorTransform()
Gets the colour transform. |
int |
getIdentifier()
Gets the identifier of the object to be placed. |
int |
getLayer()
Gets the Layer on which the object will be displayed in the display list. |
java.lang.String |
getName()
Gets the name of the object. |
int |
getPlaceType()
Gets the type of place operation being performed. |
float |
getRatio()
Gets the morph ratio, in the range 0.0 to 1.0 that defines the progress in the morphing process performed by the Flash Player from the defined start and end shapes. |
FSCoordTransform |
getTransform()
Gets the coordinate transform. |
int |
length(FSCoder coder)
|
void |
setClipEvents(java.util.ArrayList anArray)
Set the array of Clip events. |
void |
setClippingDepth(int aNumber)
Sets the number of layers that this object will mask. |
void |
setColorTransform(FSColorTransform aTransform)
Sets the colour transform that defines the colour effects applied to the object. |
void |
setEncodedEvents(byte[] bytes)
Set the encoded clip event objects generated by the classes in the Translate framework. |
void |
setIdentifier(int anIdentifier)
Sets the identifier of the object. |
void |
setLayer(int aLayer)
Sets the layer at which the object will be placed. |
void |
setName(java.lang.String aString)
Set the name of an object to be displayed. |
void |
setPlaceType(int aType)
Sets the type of placement. |
void |
setRatio(float aNumber)
Sets point of the morphing process for a morph shape in the range 0..1. |
void |
setTransform(FSCoordTransform aTransform)
Sets the coordinate transform that defines the position where the object will be 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 |
Field Detail |
---|
public static final int Modify
public static final int New
public static final int Replace
Constructor Detail |
---|
public FSPlaceObject2(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSPlaceObject2(int anIdentifier, int aLayer, int xLocation, int yLocation)
anIdentifier
- the identifier of a new object to be displayed.aLayer
- the layer number on which an object is being displayed.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int anIdentifier, int aLayer, float aRatio, int xLocation, int yLocation)
anIdentifier
- the identifier of a new object to be displayed.aLayer
- the layer number on which an object is being displayed.aRatio
- the ratio of the progress in morphing the shape.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int anIdentifier, int aLayer, FSCoordTransform aTransform)
anIdentifier
- the identifier of a new object to be displayed.aLayer
- the layer number on which an object is being displayed.aTransform
- an FSCoordTransform object that will be applied to the object
displayed in the display list at layer, aLayer.public FSPlaceObject2(int anIdentifier, int aLayer, FSCoordTransform aTransform, FSColorTransform aColorTransform)
anIdentifier
- the identifier of a new object to be displayed.aLayer
- the layer number on which an object is being displayed.aTransform
- an FSCoordTransform object that will be applied to the object
displayed in the display list at layer, aLayer.aColorTransform
- a FSColorTransform object that will be applied to the object
displayed in the display list at layer, aLayer.public FSPlaceObject2(int anIdentifier, int aLayer, int aDepth, int xLocation, int yLocation)
anIdentifier
- the identifier of a new object to be displayed.aLayer
- the layer number on which an object is being displayed.aDepth
- the layer number up to which objects will be clipped by this
object's outline.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int anIdentifier, int aLayer, java.util.ArrayList anArray, java.lang.String aName, int xLocation, int yLocation)
anIdentifier
- the identifier of a new movie clip to be displayed.aLayer
- the layer number on which the clip is being displayed.anArray
- an array of FSClipEvent objects that define the events
responded to by the movie clip.aName
- a c-string that define a name for the movie clip.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int anIdentifier, int aLayer, byte[] bytes, java.lang.String aName, int xLocation, int yLocation)
anIdentifier
- the identifier of a new movie clip to be displayed.aLayer
- the layer number on which the clip is being displayed.bytes
- an array of encoded clip event objects.aName
- a c-string that define a name for the movie clip.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int anIdentifier, int aLayer)
anIdentifier
- the identifier of the object that will replaced the one
current displayed on aLayer.aLayer
- the layer number on which the object being replaced is
displayed.public FSPlaceObject2(int aLayer, int xLocation, int yLocation)
aLayer
- the layer number on which the object is being displayed.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int aLayer, FSCoordTransform transform)
aLayer
- the layer number on which the object is being displayed.transform
- an FSCoordTransform object that will be applied to the object
displayed in the display list at layer, aLayer.public FSPlaceObject2(int aLayer, FSColorTransform colorTransform)
aLayer
- the layer number on which the object is being displayed.colorTransform
- an FSColorTransform object that will be applied to the object
displayed in the display list at layer, aLayer.public FSPlaceObject2(int aLayer, FSCoordTransform transform, FSColorTransform colorTransform)
aLayer
- the layer number on which the object is being displayed.transform
- an FSCoordTransform object that will be applied to the object
displayed in the display list at layer, aLayer.colorTransform
- an FSColorTransform object that will be applied to the object
displayed in the display list at layer, aLayer.public FSPlaceObject2(int aLayer, float aRatio, int xLocation, int yLocation)
aLayer
- the layer number on which the object is being displayed.aRatio
- the ratio of the progress in morphing the shape.xLocation
- the x-coordinate where the object will be displayed.yLocation
- the y-coordinate where the object will be displayed.public FSPlaceObject2(int aLayer, float aRatio, FSCoordTransform transform)
aLayer
- the layer number on which the object is being displayed.aRatio
- the ratio of the progress in morphing the shape.transform
- an FSCoordTransform object that will be applied to the object
displayed.public FSPlaceObject2(int aPlace, int anIdentifier, int aLayer, FSCoordTransform transform, FSColorTransform colorTransform)
aPlace
- the type of operation to be performed, either New, Modify or
Replace.anIdentifier
- the identifier of a new object to be displayed.aLayer
- the layer number on which an object is being displayed.transform
- an FSCoordTransform object that will be applied to the object
displayed in the display list at layer, aLayer.colorTransform
- an FSColorTransform object that will be applied to the object
displayed in the display list at layer, aLayer.public FSPlaceObject2(FSPlaceObject2 obj)
obj
- an FSPlaceObject2 object.Method Detail |
---|
public void add(FSClipEvent aClipEvent)
aClipEvent
- a clip event object.public java.util.ArrayList getClipEvents()
public void setClipEvents(java.util.ArrayList anArray)
anArray
- an array of FSClipEvent objects.public void setEncodedEvents(byte[] bytes)
bytes
- the array of encoded clip events.public int getPlaceType()
public int getLayer()
public int getIdentifier()
public FSCoordTransform getTransform()
public FSColorTransform getColorTransform()
public float getRatio()
public int getClippingDepth()
public java.lang.String getName()
public void setPlaceType(int aType)
aType
- the type of operation to be performed, either New, Modify or
Replace.public void setLayer(int aLayer)
aLayer
- the layer number on which the object is being displayed.public void setIdentifier(int anIdentifier)
anIdentifier
- the identifier of a new object to be displayed.public void setTransform(FSCoordTransform aTransform)
aTransform
- an FSCoordTransform object that will be applied to the object
displayed.public void setColorTransform(FSColorTransform aTransform)
aTransform
- an FSColorTransform object that will be applied to the object
displayed.public void setRatio(float aNumber)
aNumber
- the progress in the morphing process.public void setClippingDepth(int aNumber)
aNumber
- the number of layers clipped.public void setName(java.lang.String aString)
aString
- the name assigned to the object.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 |