com.flagstone.transform.button
Class ButtonShape

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

public final class ButtonShape
extends Object
implements SWFEncodeable, Copyable<ButtonShape>

ButtonShape identifies the shape that is drawn when a button is in a particular state. Shapes can be drawn for each of three button states, Over, Up and Down allowing simple animations to be created when a button is clicked.

A shape is also used to define active area of the button. When defining the active area the outline of the shape defines the boundary of the area, the shape itself is not displayed. The button will only respond to mouse events when the cursor is placed inside the active area.

The order in which shapes are displayed is controlled by the layer number. As with the Flash Player's display list shapes on a layer with a higher number are displayed in front of ones on a layer with a lower number. A coordinate and color transform can also be applied to each shape to change its appearance when it is displayed when the button enters the specified state.

See Also:
DefineButton, DefineButton2

Constructor Summary
ButtonShape()
          Creates am uninitialised ButtonShape object.
ButtonShape(ButtonShape object)
          Creates and initialises a ButtonShape object using the values copied from another ButtonShape object.
ButtonShape(SWFDecoder coder, Context context)
          Creates and initialises a ButtonShape object using values encoded in the Flash binary format.
 
Method Summary
 ButtonShape add(Filter filter)
          Add a Filter to the list of Filters that will be applied to the shape.
 ButtonShape addState(ButtonState buttonState)
          Add the state to the list of states that the shape is displayed for.
 ButtonShape copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Blend getBlend()
          Get the Blend that defines how the shape is blended with background shapes that make up the button.
 ColorTransform getColorTransform()
          Get the colour transform that will be applied to the button.
 List<Filter> getFilters()
          Get the list of Filters that will be applied to the shape.
 int getIdentifier()
          Get the unique identifier of the shape that this Button applies to.
 int getLayer()
          Get the layer that the button will be displayed on.
 Set<ButtonState> getState()
          Get the list of states that the shape is displayed for.
 CoordTransform getTransform()
          Get the coordinate transform that will be applied to the button.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 ButtonShape setBlend(Blend mode)
          Set the Blend that defines how the shape is blended with background shapes that make up the button.
 ButtonShape setColorTransform(ColorTransform cxform)
          Sets the colour transform that will be applied to the shape to change it's colour.
 ButtonShape setFilters(List<Filter> list)
          Set the list of Filters that will be applied to the shape.
 ButtonShape setIdentifier(int uid)
          Sets the unique identifier of the DefineShape, DefineShape2 or DefineShape3 object that defines the appearance of the button when it is in the specified state(s).
 ButtonShape setLayer(int aNumber)
          Sets the layer in the display list that the shape will be displayed on.
 ButtonShape setState(Set<ButtonState> states)
          Set the list of states that the shape is displayed for.
 ButtonShape setTransform(CoordTransform matrix)
          Sets the coordinate transform that will be applied to the shape to change it's appearance.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ButtonShape

public ButtonShape(SWFDecoder coder,
                   Context context)
            throws IOException
Creates and initialises a ButtonShape 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.

ButtonShape

public ButtonShape()
Creates am uninitialised ButtonShape object.


ButtonShape

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

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

getState

public Set<ButtonState> getState()
Get the list of states that the shape is displayed for.

Returns:
the list of button states that define when the shape is displayed.

setState

public ButtonShape setState(Set<ButtonState> states)
Set the list of states that the shape is displayed for.

Parameters:
states - the list of button states that define when the shape is displayed.
Returns:
this object.

addState

public ButtonShape addState(ButtonState buttonState)
Add the state to the list of states that the shape is displayed for.

Parameters:
buttonState - the state that defines when the shape is displayed.
Returns:
this object.

getIdentifier

public int getIdentifier()
Get the unique identifier of the shape that this Button applies to.

Returns:
the unique identifier of the shape.

setIdentifier

public ButtonShape setIdentifier(int uid)
Sets the unique identifier of the DefineShape, DefineShape2 or DefineShape3 object that defines the appearance of the button when it is in the specified state(s).

Parameters:
uid - the unique identifier of the shape object that defines the shape's appearance. Must be in the range 1..65535.
Returns:
this object.

getLayer

public int getLayer()
Get the layer that the button will be displayed on.

Returns:
the layer that the shape is displayed on.

setLayer

public ButtonShape setLayer(int aNumber)
Sets the layer in the display list that the shape will be displayed on.

Parameters:
aNumber - the number of the layer in the display list where the shape is drawn. Must be in the range 1..65535.
Returns:
this object.

getTransform

public CoordTransform getTransform()
Get the coordinate transform that will be applied to the button.

Returns:
the coordinate transform that is applied to the shape.

setTransform

public ButtonShape setTransform(CoordTransform matrix)
Sets the coordinate transform that will be applied to the shape to change it's appearance.

Parameters:
matrix - a CoordTransform object that will be applied to the shape. Must not be null.
Returns:
this object.

getColorTransform

public ColorTransform getColorTransform()
Get the colour transform that will be applied to the button. Note that the colour transform will only be used if the ButtonShape is added to a DefineButton2 object.

Returns:
the colour transform that is applied to the shape.

setColorTransform

public ButtonShape setColorTransform(ColorTransform cxform)
Sets the colour transform that will be applied to the shape to change it's colour. IMPORTANT: The colour transform is only used in DefineButton2 objects.

Parameters:
cxform - a ColorTransform object that will be applied to the shape. Must not be null, even if the ButtonShape will be added to a DefineButton object.
Returns:
this object.

add

public ButtonShape add(Filter filter)
Add a Filter to the list of Filters that will be applied to the shape.

Parameters:
filter - a Filter to apply to the button shape.
Returns:
this object.

getFilters

public List<Filter> getFilters()
Get the list of Filters that will be applied to the shape.

Returns:
the list of filters.

setFilters

public ButtonShape setFilters(List<Filter> list)
Set the list of Filters that will be applied to the shape.

Parameters:
list - a list of Filter objects.
Returns:
this object.

getBlend

public Blend getBlend()
Get the Blend that defines how the shape is blended with background shapes that make up the button.

Returns:
the Blend mode.

setBlend

public ButtonShape setBlend(Blend mode)
Set the Blend that defines how the shape is blended with background shapes that make up the button.

Parameters:
mode - the Blend mode for this shape.
Returns:
this object.

copy

public ButtonShape copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<ButtonShape>
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.