com.flagstone.transform
Class DoAction

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

public final class DoAction
extends Object
implements MovieTag

DoAction is used to add a set of actions to a frame in a movie. The actions will be triggered when the Flash Player executes the ShowFrame command.

Only one DoAction object can be used to specify the actions for a given frame. If more than one DoAction object is added in a single frame only the actions contained in the last DoAction object (before the ShowFrame object) will be executed when the frame is displayed. The other DoAction objects will be ignored.

IMPORTANT: The last action in the list must be BasicAction.END otherwise the object will not be encoded correctly.

When decoding a movie, if the decode actions flag is set to false then the actions will be decoded as a single ActionData object containing the encoded actions.

DoAction can only be used in movies that contain Actionscript 1.x or Actionscript 2.x code. For Actionscript 3.0 use the DoABC class.


Constructor Summary
DoAction()
          Creates a new DoAction class with an empty list.
DoAction(DoAction object)
          Creates a DoAction object with a copy of the actions from another DoAction object.
DoAction(List<Action> list)
          Creates a DoAction object with a list of actions.
DoAction(SWFDecoder coder, Context context)
          Creates and initialises a DoAction object using values encoded in the Flash binary format.
 
Method Summary
 DoAction add(Action anAction)
          Adds the action object to the list of actions.
 DoAction 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()
          Returns the list of actions that are executed when the frame is displayed.
 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)
          Set the list of actions that will be executed when the next ShowFrame tag is executed by the Flash Player.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoAction

public DoAction(SWFDecoder coder,
                Context context)
         throws IOException
Creates and initialises a DoAction 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 pass values when decoding objects.
Throws:
IOException - if an error occurs while decoding the data.

DoAction

public DoAction()
Creates a new DoAction class with an empty list.


DoAction

public DoAction(List<Action> list)
Creates a DoAction object with a list of actions.

Parameters:
list - the list of action objects. Cannot be null.

DoAction

public DoAction(DoAction object)
Creates a DoAction object with a copy of the actions from another DoAction object.

Parameters:
object - a DoAction object to copy.
Method Detail

add

public DoAction add(Action anAction)
Adds the action object to the list of actions. If the object already contains encoded actions then they will be deleted.

Parameters:
anAction - an object belonging to a class derived from Action. The argument cannot be null.
Returns:
this object.

getActions

public List<Action> getActions()
Returns the list of actions that are executed when the frame is displayed.

Returns:
the list of action objects.

setActions

public void setActions(List<Action> list)
Set the list of actions that will be executed when the next ShowFrame tag is executed by the Flash Player. If the object already contains encoded actions then they will be deleted.

Parameters:
list - the list of action objects. May be empty but cannot be null.

copy

public DoAction 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.