-
Notifications
You must be signed in to change notification settings - Fork 0
Introduction
tsclausing edited this page Dec 31, 2010
·
11 revisions
The introduction below defines an ActionScript class and a function to be used in a simple Hello World example.
public class MyCommandClass {
public function execute(...args) :void {
// do something, like make a service call for data, perform some business logic, or return a value to the caller.
trace("Hello World from a Command class");
}
}
When Trigger executes a Command, it creates a new instance of the class and then invokes a method, returning any value back to the caller.
function myCallbackFunction(...args) :void {
// do something, like change the state of your application or return a value to the caller.
trace("Hello World from a Callback function");
}
When Trigger executes a Callback, it invokes the function, returning any value back to the caller.
Main.as
// Adding a Command
addCommand("trigger1", MyCommandClass);
// Adding a Callback
addCallback("trigger2", myCallbackFunction);
Anywhere.as
// Trigger the Command
trigger("trigger1");
// Trigger the Callback
trigger("trigger2");
Console Output
Hello World from a Command class
Hello World from a Callback function
This example illustrates the simplicity of Trigger. No configuration files, no classes to extend and no overt framework code in your application - just a simple global function API for Commands and Callbacks.