Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Apollo is an dependency injection and messaging framework. It can be used as the basis for Actionscript MVC projects.
Tree: 271b77cad0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples/Hello World


AS3 Apollo

Apollo is an dependency injection and message passing framework based on public interfaces.

It is lightweight, fast and easy to use.

Usage of introspection is optional, depending on the amount of control you want to have and on performance requirements.

Code sample

Code below will set-up a minimal actionscript application using Apollo. Notice the (nearly) complete lack of boiler-plate code.

We have to create an interface that will serve as a mapping proxy. In this example we will map the Person class to this interface.

public interface IPersonInjectable
   function set person(val:Person):void;

Set up our person value object.

public class Person{

   public var first_name:String;
   public var last_name:String;

   function Person(fist_name:String, last_name:String)
    this.first_name = first_name;
    this.last_name = last_name;

Our controller has to implement the above interface for the injection to work. Controllers will auto-register, so no code to be written.

public class PersonViewController extends Controller implements IPersonInjectable
   public function PersonViewController() 

   public function set person(val:Person):void
      view.person = val;
      trace(val.first_name + ' ' + val.last_name)

In our main class we have to do two things for this example to work.

  • Register interfaces
  • Instatiate a controller

Now we can inject a message of type Person. Magic.

// Register our interfaces used to construct our mappings
Injector.interfaces = [IPersonInjectable];

// Create our controller
new PersonViewController();

//Inject a message
Injector.inject(new Person('Laurent', 'Zuijdwijk'))

Performance considerations

I didn't do any benchmarking yet, but I expect performance to be pretty good. The introspection part is pretty lightweight, mainly because it is only done on a limited set of interfaces. But if you want to contruct mappings manually, this is possible as well. See the example below.

var injectorMap:Vector.<InjectorMapping> = new Vector.<InjectorMapping>();
injectorMap.push(new InjectorPropertyMapping(IPersonInjectable, 'person', Person));
Injector.model = injectorMap;
Something went wrong with that request. Please try again.