Class Command
{
// fields
Private Var Receiver: Receiver;
// conntructors
Private function command (receiver: receiver)
{
This.Receiver = Receiver;
}
//Methods
PUBLIC FUNCTION EXECUTE (): void {};
}
// "Receiver"
Class Receiver
{
//Methods
Public function action (): void
{
"" Called received () ");
}
}
// "Invoker"
Class Invoker
{
// fields
Private var command: Command;
//Methods
Public Function SetCommand (Command: Command): Void
{
this.command = Command;
}
Public function executeCommand (): void
{
Command.execute ();
}
}
// "ConcreteCommand"
Class ConcreteCommand Extends Command
{
// conntructors
Public Function ConcreteCommand (Receiver: Receiver)
{
Super (Receiver);
}
//Methods
Public function execute (): void
{
Receiver.Action ();
}
}
//client.fla
// Create Receiver, Command, And Invoker
Var r: receiver = new receiver ();
Var c: command = new concreteCommand (R);
VAR i: invoker = new invoker ();
// SET and Execute Command
I.setCommand (C);
I.executeCommand ();
// caled receiver.Action ()