Batch

Kind of class:public class
Package:com.bourre.commands
Inherits from:AbstractCommand
Implements:
Known subclasses:
Classpath:com.bourre.commands.Batch
File last modified:Sunday, 10 February 2008, 10:49:13

Summary


Constructor
Class methods
  • process (f:Function, a:Array, args) : void
    • Takes all elements of an Array and pass them one by one as arguments
Instance methods
  • addCommand (command:Command) : Boolean
    • Adds a command in the batch stack.
  • setOwner (owner:Plugin) : void
  • removeCommand (command:Command) : Boolean
    • Removes all references to the passed-in command.
  • contains (command:Command) : Boolean
    • Returns true if the passed-in command is stored
  • execute (e:Event = null) : void
    • Executes the whole set of commands in the order they were
  • removeAll : void
    • Removes all commands stored in the batch stack.
  • size : uint
    • Returns the number of commands stored in this batch.

Constructor

Batch

public function Batch (
)

Batch object don't accept any arguments in the constructor.

Class methods

process

public static function process (
f:Function, a:Array, args) : 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 .4 and scale to 50
on all MovieClips nested in the Array :

Parameters:
f :
function to run.
a :
array of parameters.
args:
additionnal parameters to concat with the passed-in
arguments array
Example:

  • import com.bourre.commands.*;

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

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

Instance methods

addCommand

public function addCommand (
command:Command) : Boolean

Adds a command in the batch stack.

If the passed-in command have been added the
function return true.

There is no limitation on the number of references
of the same command witch the batch can contain.

Parameters:
command:
a Command to add at the end
of the current Batch
Returns:
  • true if the command could have been added,
    either false

contains

public function contains (
command:Command) : Boolean

Returns true if the passed-in command is stored
in this batch.
Parameters:
command:
command object to look at
Returns:
  • true if the passed-in command is stored
    in the Batch

execute

override public function execute (
e:Event = null) : void

Executes the whole set of commands in the order they were
registered.

If an event is passed to the function, it will be relayed
to the sub-commands execute method.

Parameters:
e:
event object to relay to the sub-commands.
Overrides:
  • AbstractCommand.execute
Throws:
  • {VISDOC_LINK_0}execute — Stateless command use the passed-in event
    as data source for its execution, so the event must provide the right data for
    the current true object.
    #
Specified by:

removeAll

public function removeAll (
) : void

Removes all commands stored in the batch stack.

removeCommand

public function removeCommand (
command:Command) : Boolean

Removes all references to the passed-in command.

If the command have been found and removed
from the Batch the function return

true.

Parameters:
command:
command object to be removed
Returns:
  • true if the command have been
    successfully removed.

setOwner

override public function setOwner (
owner:Plugin) : void

Overrides:
  • AbstractCommand.setOwner

size

public function size (
) : uint

Returns the number of commands stored in this batch.
Returns:
  • the number of commands stored in this batch