Batch

Kind of class:class
Inherits from:none
Implements:
Version:1.0
Author:Francis Bourre
Classpath:com.bourre.commands.Batch
File last modified:Wednesday, 31 October 2007, 07:35:29
Batch is a concrete implementation of MacroCommand interface.

It handles several commands as one command.

Basical example :

Example:
import com.bourre.commands.*;

function test(s)
{
    trace(s);
}

function sum(x, y)
{
    var n = x+y;
    trace("sum result : " + n);
}

var d0:Delegate = new Delegate(this, test, 'hello world');
var d1:Delegate = new Delegate(this, sum, 3, 4);

var b:Batch = new Batch();
b.addCommand(d0);
b.addCommand(d1);
b.execute();

Constructor

Batch

function Batch (
)
MacroCommand implementation.
See also:

Class methods

create

static function create (
) : Function
Creates batch instance and returns method reference that runs the whole commands stack.
Example:
myButton.onPress = Batch.create(myCommand0, myCommand1, myCommand2);
Returns:
Function.
See also:

process

static function process (
f:Function, a:Array) : Void
Takes all elements of an Array and pass them one by one as arguments
to a method of an object.
It's exactly the same concept as batch processing in audio or video
software, when you choose to run the same actions on a group of files.

Basical example which sets _alpha value to 10 and scale to 50
on all MovieClips nested in the Array :

Parameters:
o:
Context in which to run the function.
f:
Function to run.
a:
Array of parameters.
Example:
import com.bourre.commands.*;

function changeAlpha(mc, a, s);	 * {
    mc._alpha = a;
    mc._xscale = mc._yscale = s;
}

Batch.process(this, changeAlpha, [mc0, mc1, mc2], 10, 50);

Instance methods

addCommand

function addCommand (
oC:Command) : Void
Add command to Batch instance.
Parameters:
oC:
Command instance to add.
See also:

execute

function execute (
e:IEvent) : Void
Execute all commands stored in Batch instance.
Command polymorphism.
See also:
com.bourre.commands.command
Specified by:

getFunction

function getFunction (
) : Function
Get method reference that runs the whole commands stack.
Returns:
Function that delegates its call to a different scope, method and arguments.

getLength

function getLength (
) : Number
Get amount of stored commands.
Returns:
Number.

removeAll

function removeAll (
) : Void
Remove all commands.
Each command added will be removed, it means that they won't be executed anymore.
Warning, because you can't undo this method's behaviour.

removeCommand

function removeCommand (
oC:Command) : Void
Remove command to Batch instance.
Parameters:
oC:
Command instance to remove.
See also:

toString

function toString (
) : String
Returns the string representation of this instance.
Returns:
the string representation of this instance