|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSLayer
public final class FSLayer
The Layer class can be used to simplify the creation of movies. It provides a series of methods that can be used to control how an object is displayed and provides an API that is easier to use when compared to creating the commands (FSPlaceObject, FSRemoveObject, etc.) used to manipulate the Flash Player's display list directly. The following code:
FSLayer layer = new Layer(1); layer.select(shape); layer.move(x1, y1); layer.show(); layer.move(x2, y2); layer.show(); movie.add(layer.getObjects());is equivalent to:
movie.add(shape); movie.add(new FSPlaceObject2(shape.getIdentifier, 1, x1, y1)); movie.add(FSShowFrame.getInstance()); movie.add(new FSPlaceObject2(1, x2, y2)); movie.add(FSShowFrame.getInstance());After each set of commands the display list is updated by executing the show() method - this adds a ShowFrame instruction to the final movie which tells the Flash Player to render the display list on the screen. The select() method is only used when displaying an object for the first time or re-displaying it after it was deleted from the display list. The commands that manipulate the display list can also be combined to apply several operations at once:
layer.select(shape); layer.move(x, y); layer.morph(0.9); layer.color(r, g, b); layer.show();is equivalent to:
FSCoordTransform coord = new FSCoordTransform(x, y); FSColorTransform color = new FSColorTransform(r, g, b); FSPlaceObject2 place = new FSPlaceObject2(shape.getIdentifier, 1, coord, color) place.setRatio(0.9); movie.add(shape); movie.add(place); movie.add(FSShowFrame.getInstance());An operation is use to set the attributes on either an FSPlaceObject2 or FSRemoveObject2 object so operations of the same type cannot be combined to create a cumulative effect. For example:
layer.move(x1, y1); layer.move(x2, y2);is the same as:
layer.move(x2, y2);and not:
layer.move(x1 + x2, y1 + y2);The most obvious benefit is code that is easier to write and read however the benefits of using layers come to the fore when creating movies with multiple objects. Currently the movie object represents the main time-line and the commands to control and display each object must be interleaved together. This quickly becomes unwieldy and error prone if several objects are involved. With layers, each can be regarded as the time-line for a single object. The object can then be manipulated more easily and the final set of Layers merged together to create a single time-line. The only limitation in the merging process is that all the Layers must start at the same point in time. Each Layer object created must be assigned a unique number. In Flash an object to be displayed is assigned to a given layer with (typically) only one object displayed on a given layer. The layer number is used to control the order in which the objects are displayed. Objects placed on a higher layer number are displayed in front of object placed on a lower layer number.
Constructor Summary | |
---|---|
FSLayer(int number)
Create a new Layer object. |
Method Summary | |
---|---|
void |
add(FSDefineObject definition)
Add an object to the layer. |
void |
change(FSColorTransform color)
Change the colour of the object by applying a color transform. |
void |
change(FSCoordTransform coord)
Change the position, orientation and scaling of the object by applying a 2D coordinate transform. |
void |
clip(int depth)
Set the number of layers that the outline of the object will clip when placed on the display list. |
void |
color(int r,
int g,
int b)
Change the colour of the object to the values (r,g,b). |
void |
color(int r,
int g,
int b,
int a)
Change the colour of the object to the values (r,g,b,a). |
int |
getIdentifier()
Return the identifier of the object on the layer. |
int |
getLayer()
Return the layer number. |
java.util.ArrayList |
getObjects()
Return the array of commands used to manipulate the object on the display list. |
static java.util.ArrayList |
merge(java.util.ArrayList layers)
Merge layers together to create a single time-line. |
void |
morph(float ratio)
Set the point in the morphing process for a morph shape in the range 0.0 to 1.0. |
void |
move(int x,
int y)
Set the coordinates where the object will be displayed. |
void |
name(java.lang.String name)
Assign a name to the object. |
void |
remove()
Remove the object from the display list. |
void |
replace(int id)
Replace the object on the display list. |
void |
select(FSDefineObject definition)
Add an object to the later and select it to be added on the display list. |
void |
select(int id)
Select the object previously added to the layer to be added on the display list. |
void |
show()
Instruct the Flash Player to display a frame and render the contents of the display list, applying the commands previously set. |
void |
show(int count)
Display one or more frames. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FSLayer(int number)
number
- the layer number on the display list.Method Detail |
---|
public static java.util.ArrayList merge(java.util.ArrayList layers)
layers
- and array of FSLayer objects.
public int getLayer()
public int getIdentifier()
public java.util.ArrayList getObjects()
public void add(FSDefineObject definition)
definition
- an object defining an image, shape, text, sound or video.public void select(int id)
id
- an object definition, FSDefineShape, FSDefineImage, etc. that
will be added to the display list.public void select(FSDefineObject definition)
definition
- an object definition, FSDefineShape, FSDefineImage, etc. that
will be added to the display list.public void move(int x, int y)
x
- the x-coordinate, expressed in twips.y
- the y-coordinate, expressed in twips.public void color(int r, int g, int b)
r
- the red component of the colour.g
- the green component of the colour.b
- the blue component of the colour.public void color(int r, int g, int b, int a)
r
- the red component of the colour.g
- the green component of the colour.b
- the blue component of the colour.a
- the transparency component.public void clip(int depth)
depth
- the number of layers that will be clipped.public void morph(float ratio)
ratio
- the ratio between the starting shape and the end shape.public void name(java.lang.String name)
name
- a string that can be used to reference the object.public void remove()
public void replace(int id)
public void change(FSColorTransform color)
color
- the color transform to apply to the shape.public void change(FSCoordTransform coord)
coord
- the coordinate transform to apply to the object.public void show()
public void show(int count)
count
- the number of frames to be displayed.
java.lang.IllegalArgumentException
- is the number of frames is less than 1.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |