AS3-Signals in Swiz, keepin' it simple

AS3-Signals in Swiz, keepin' it simple

Rene Rubalcava | February 18, 2010

So, previously I had talked about using Swiz and AS3-Signals (Swignalz!). My example was crude and honestly, it was not good. Ben Clinkinbeard did a much better job of showing how easy it was to drop some AS3-Signals around with Swiz.

This past week, I have been tinkering around with a project that will be redone and figured out that if you create a named Bean for a regular Signal, you can then Inject/Autowire that Bean into any Signal in your application. var mySigBean:Bean = new Bean(new Signal(), "mySignal");

This turns out real nice because then all I have to do anywhere in my application is the following. [Inject("mySignal")] public var signal:Signal;

There's no need to create a custom Signal in your application, even if you are going to dispatch a payload. No more signals folder for me. I'm not sure if there is a performance hit for not defining the type of Object that will be dispatched with your Signal, but so far this has turned out pretty well for me.

I threw together a quick example with source here. I'd also like to point out that Swiz 1.0 metadata Injecttion into view components is really nice and lets me do cool things like this. [Inject(source="mySignal", destination="frmSignal")]

That is so cool.