com.flagstone.transform
Class LimitScript

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

public final class LimitScript
extends Object
implements MovieTag

The LimitScript is used to define the execution environment of the Flash Player, limiting the resources available when executing actions and improving performance.

LimitScript can be used to limit the maximum recursion depth and limit the time a sequence of actions can execute for. This provides a rudimentary mechanism for people viewing a movie to regain control of the Flash Player should a script fail.


Constructor Summary
LimitScript(int stackDepth, int timeLimit)
          Creates a LimitScript object that limits the recursion depth to depth levels and specifies that any sequence of actions will timeout after timeout seconds.
LimitScript(LimitScript object)
          Creates and initialises a LimitScript object using the values copied from another LimitScript object.
LimitScript(SWFDecoder coder)
          Creates and initialises a LimitScript object using values encoded in the Flash binary format.
 
Method Summary
 LimitScript copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 int getDepth()
          Get the maximum stack depth for function execution.
 int getTimeout()
          Get the maximum time a sequence of actions will execute before the Flash Player present a dialog box asking whether the script should be terminated.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setDepth(int stackDepth)
          Sets the maximum recursion level.
 void setTimeout(int time)
          Sets the maximum time a sequence of actions will execute before the Flash Player present a dialog box asking whether the script should be terminated.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LimitScript

public LimitScript(SWFDecoder coder)
            throws IOException
Creates and initialises a LimitScript object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

LimitScript

public LimitScript(int stackDepth,
                   int timeLimit)
Creates a LimitScript object that limits the recursion depth to depth levels and specifies that any sequence of actions will timeout after timeout seconds.

Parameters:
stackDepth - the maximum depth a sequence of actions can recurse to. Must be in the range 0..65535.
timeLimit - the time in seconds that a sequence of actions is allowed to execute before the Flash Player displays a dialog box asking whether the script should be terminated. Must be in the range 0..65535.

LimitScript

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

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

getDepth

public int getDepth()
Get the maximum stack depth for function execution.

Returns:
the maximum number of stack frames for recursive functions.

setDepth

public void setDepth(int stackDepth)
Sets the maximum recursion level.

Parameters:
stackDepth - the maximum depth a sequence of actions can recurse to. Must be in the range 0..65535.

getTimeout

public int getTimeout()
Get the maximum time a sequence of actions will execute before the Flash Player present a dialog box asking whether the script should be terminated.

Returns:
the maximum execution time of a script.

setTimeout

public void setTimeout(int time)
Sets the maximum time a sequence of actions will execute before the Flash Player present a dialog box asking whether the script should be terminated.

Parameters:
time - the time in seconds that a sequence of actions is allowed to execute. Must be in the range 0..65535.

copy

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