com.flagstone.transform
Class FSRegisterIndex

java.lang.Object
  extended by com.flagstone.transform.FSTransformObject
      extended by com.flagstone.transform.FSRegisterIndex
All Implemented Interfaces:
java.lang.Cloneable

public class FSRegisterIndex
extends FSTransformObject

FSRegisterIndex is used with an FSPush action to refer to one of the Flash Player's internal registers that contains a value to be used in a calculation.

The number of registers in the Flash Player was increased in Flash 7 to 256.

The Flash Player uses a stack to store values when executing the actions associated with a button being pushed, frame being played, etc. If a value is used repeatedly in a calculation, it must be pushed onto the stack each time using an FSPush action. To speed up the execution of the calculation and reduce the amount of code required the value can be saved to one of the internal registers of the Flash Player using the FSRegisterCopy action (which copies the value currently at the top of the stack into the specified register). An FSRegisterIndex creates a reference to the register so the Flash Player uses the value directly rather than popping it from the stack.

To copy a value from the top of the stack to one of the Flash Player's internal registers specify the register number in the constructor for the FSRegisterCopy class:

  ArrayList actions = new ArrayList();
  ...
  actions.add(new FSRegisterCopy(0));
  ...
 

References to one of the Flash Player's internal registers are created using the FSRegisterIndex class and pushing it onto the stack using the FSPush class. When the value is used in a calculation then the value will be retrieved from the specified register.

  FSPush push = new FSPush();
  push.add(new FSRegisterIndex(0));
  ...
  actions.add(push);
  ...
 

History

The RegisterCopy action and access to the Flash Player's internal registers was introduced in Flash 5. The number of registers supported was expanded in Flash 7 to 256.


Constructor Summary
FSRegisterIndex(FSCoder coder)
          Construct an FSRegisterIndex object, initalizing it with values decoded from an encoded object.
FSRegisterIndex(FSRegisterIndex obj)
          Constructs an FSRegisterIndex object by copying values from an existing object.
FSRegisterIndex(int anIndex)
          Constructs an FSRegisterIndex object referencing the value stored in one of the Flash Player's internal registers.
 
Method Summary
 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.
 void decode(FSCoder coder)
           
 void encode(FSCoder coder)
           
 boolean equals(java.lang.Object anObject)
          Returns true if anObject is equal to this one.
 int getIndex()
          Gets the number of the Flash Player's internal register.
 int length(FSCoder coder)
           
 void setIndex(int anIndex)
          Sets the number of the Flash Player's internal register.
 
Methods inherited from class com.flagstone.transform.FSTransformObject
clone, name, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FSRegisterIndex

public FSRegisterIndex(FSCoder coder)
Construct an FSRegisterIndex object, initalizing it with values decoded from an encoded object.

Parameters:
coder - an FSCoder containing the binary data.

FSRegisterIndex

public FSRegisterIndex(int anIndex)
Constructs an FSRegisterIndex object referencing the value stored in one of the Flash Player's internal registers.

Parameters:
anIndex - the register number.

FSRegisterIndex

public FSRegisterIndex(FSRegisterIndex obj)
Constructs an FSRegisterIndex object by copying values from an existing object.

Parameters:
obj - an FSRegisterIndex object.
Method Detail

getIndex

public int getIndex()
Gets the number of the Flash Player's internal register.

Returns:
the register number.

setIndex

public void setIndex(int anIndex)
Sets the number of the Flash Player's internal register.

Parameters:
anIndex - the register number.

equals

public boolean equals(java.lang.Object anObject)
Description copied from class: FSTransformObject
Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

Overrides:
equals in class FSTransformObject
Returns:
true if this object would be identical to anObject when encoded.

appendDescription

public void appendDescription(java.lang.StringBuffer buffer,
                              int depth)
Description copied from class: FSTransformObject
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

Specified by:
appendDescription in class FSTransformObject
Parameters:
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.

length

public int length(FSCoder coder)
Specified by:
length in class FSTransformObject

encode

public void encode(FSCoder coder)
Specified by:
encode in class FSTransformObject

decode

public void decode(FSCoder coder)
Specified by:
decode in class FSTransformObject