Frameworks

Robot Legs & FlexUnit4 – EventDispatchers wo/Injector

This should be obvious, but in case you have a brain fart like I did earlier. If your looking to test a Robot Leg Actor. And you want to listen for events coming out of the Actor. Here is a easy way to do it.

The main purpose of this is to be able to test a individual actor. Such as a web service to make sure it as a individual is performing correctly.

Actor


public var myActor:CoolActorClass;

[Before]
public function setupActor():void {
	myActor = new CoolActorClass();
	myActor.eventDispatcher = new EventDispatcher();
}

And if your using Joel’s Modular Utility. You can do something like this.

ModularActor


public var myActor:CoolModularActorClass;

[Before]
public function setupModuleActor():void {
	myActor = new CoolModularActorClass();
	myActor.eventDispatcher = new EventDispatcher();
	myActor.moduleEventDispatcher = new ModuleEventDispatcher();
}

Now you can perform your test as if it’s running in a full blown RL Application.

Advertisements

I'm on the RobotLegs bandwagon!

I’ve been doing lots of research on Flex/AS3 Framework’s lately and found an awesome one.

http://www.robotlegs.org/

You basically create seperate objects for each part of your application.

  • View
  • Commands (Controllers)
  • Mediators (Object’s That Control the Views)
  • Context (Maps Everything Together)
  • Services (DataCalls)
  • VO (Store Data)
  • Events

The key is that every object only worries about it’s responsibilities, making it very structured and easy to debug. They for the most part don’t call direct functions of each other. Instead they create custom events and shoot them to each other. This is especially cool for Modular Apps. You can blast a event to all modules and they can each handle there own responsibility.

Very cool. You should check it out.