com.flagstone.transform.button
Class DefineButton

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

public final class DefineButton
extends Object
implements DefineTag

DefineButton defines the appearance of a button and the actions performed when the button is clicked.

DefineButton must contain at least one ButtonShape object. If more than one button shape is defined for a given button state then each shape will be displayed by the button. The order in which the shapes are displayed is determined by the layer assigned to each ButtonShape object.

See Also:
ButtonShape

Constructor Summary
DefineButton(DefineButton object)
          Creates and initialises a DefineButton object using the values copied from another DefineButton object.
DefineButton(int uid, List<ButtonShape> buttons, List<Action> script)
          Creates a DefineButton object with the identifier, button shapes and actions.
DefineButton(SWFDecoder coder, Context context)
          Creates and initialises a DefineButton object using values encoded in the Flash binary format.
 
Method Summary
 DefineButton add(Action obj)
          Adds the action to the list of actions.
 DefineButton add(ButtonShape obj)
          Adds the button shape to the list of button shapes.
 DefineButton copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 List<Action> getActions()
          Get the list of actions that will be executed when the button is clicked and released.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 List<ButtonShape> getShapes()
          Get the list of button shapes.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setActions(List<Action> list)
          Sets the list of actions that will be executed when the button is clicked and released.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 void setShapes(List<ButtonShape> list)
          Sets the list of button shapes defined for this button.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineButton

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

DefineButton

public DefineButton(int uid,
                    List<ButtonShape> buttons,
                    List<Action> script)
Creates a DefineButton object with the identifier, button shapes and actions.

Parameters:
uid - the unique identifier for this button.
buttons - a list of ButtonShapes that are used to draw the button.
script - a list of actions that are executed when the button is clicked.

DefineButton

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

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

getIdentifier

public int getIdentifier()
Get the unique identifier assigned to this object.

Specified by:
getIdentifier in interface DefineTag
Returns:
the unique identifier used by the Flash Player to reference this definition.

setIdentifier

public void setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - a unique identifier for the object. Must be in the range 1..65535.

add

public DefineButton add(ButtonShape obj)
Adds the button shape to the list of button shapes.

Parameters:
obj - an ButtonShape object. Must not be null.
Returns:
this object.

add

public DefineButton add(Action obj)
Adds the action to the list of actions.

Parameters:
obj - an action object. Must not be null.
Returns:
this object.

getShapes

public List<ButtonShape> getShapes()
Get the list of button shapes.

Returns:
the list of shapes used to represent the button.

getActions

public List<Action> getActions()
Get the list of actions that will be executed when the button is clicked and released.

Returns:
the actions executed when the button is clicked.

setShapes

public void setShapes(List<ButtonShape> list)
Sets the list of button shapes defined for this button.

Parameters:
list - a list of Button objects. Must not be null.

setActions

public void setActions(List<Action> list)
Sets the list of actions that will be executed when the button is clicked and released.

Parameters:
list - a list of action objects. Must not be null.

copy

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

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