eidiot Loving ActionScript 3

24Mar/10

SignalExecutorMap – Another way to map AS3-Signal to Command in Robotlegs

I love both Robotlegs and AS3-Signals so much, and many thanks to Joel Hooks's SignalCommandMap, they work together great now. When I saw [Execute] tag in dawn I thought if I can do its way for SignalCommand. So, Here is my SignalExecutorMap. I used it in a simple slide player for my Robotlegs slides.

To use it, put the same count and type of params in the execute() method of the Command as its trigger Signal.

// The signal in SignalBus:
public const turnToPageRequested:Signal = new Signal(int);
// Execute method in Command:
public function execute(index:int):void
// Dispatch the signal
signalBus.turnToPageRequested.dispatch(0);

It's not a common solution, because it eliminates the possibility of using other Command impls already in existence. So I created it as SignalExecutorMap instead of expanding SignalCommandMap, and just leave it a single class for personal use. I shared it just in case somebody want it like me because:

  • 1, By now (until Robotlegs 1.1) SignalCommandMap will unmap the value passed by Signal.
  • 2, Don't want to inject base type like
    [Inject]
    public var index:int;
  • 3, Don't want to create VO class just for being passed by Signal to avoid 1 and 2.

I'm sure SignalCommandMap will get better with Robotlegs 1.1 and better later. Robotlegs and as3-signals, they were born to work together :)

20Mar/10

My Robotlegs slides

I'll give a presentation about Robotlegs the end of this month, here are slides based on Joel Hooks's, Please correct me if I'm doing something wrong, many thanks. The file is on GitHub, and also valid as .key, .ppt, and .pdf format download.

Get Adobe Flash player

Tagged as: 1 Comment
10Mar/10

Robotlegs Utility LazyMediator

中文:Robotlegs 的 LazyMediator 扩展

Robotlegs utility LazyMediator is for better performance in games.

How to use
  • Override the mediatorMap getter method in context to:
    return _mediatorMap || (_mediatorMap = new LazyMediatorMap(contextView, injector));
  • In the constructor of view classes add:
    new LazyMediatorActivator(this);
Why it
  • LazyMediatorMap don’t listen events of display list and check every added/removed view.
How it works
  • LazyMediatorActivator dispatchs LazyMediatorEvent when the view is added/removed from stage.
  • LazyMediatorMap listen to the LazyMediatorEvent from contextView then check the view.