AS3 Signals – the best thing since sliced bread

If you haven’t heard about Robert Penner’s AS3 Signals yet, you’re missing out. Until yesterday I had only briefly looked at the project but after John Lindquist’s video tutorial I’m completely sold on the idea and look forward to using it in my projects.

So what is AS3 Signals suppose to do for you?

Well for one it uses composition rather than inheritance so you don’t need to have your class extend You can dispatch a “signal” and pass any number of arguments with it, no more endless subclassing of for creating your custom events.

There’s also some nice features that you don’t get with the traditional event handling in ActionScript 3.0, things like addOnce which makes sure a listener only gets triggered the first time, removeAll which removes all listeners on a Signal and numListeners that returns the number of listeners on a Signal instance.

Apart from the generic Signal class, you also have DeluxeSignal which allows you to define the target (it also has some experimental bubbling support using .parent) and the NativeSignal which lets you map native events like MouseEvent.CLICK to a Signal.

This AS3 Signals project makes for an incredibly easy way of working with events inside of ActionScript. Give it a try and let me know what you think!

Watch the video tutorial



8 thoughts on “AS3 Signals – the best thing since sliced bread

  1. Hey Peter,

    I’ve seen the basic used in many AS3/Flex projects before where you have one custom event class with an Object property to avoid having to create a massive amount of custom event classes. However, that system doens’t have type checking, whereas this one (I suppose) does.

    Looks promising and I will give it a try when I find the time…


  2. Max says:

    I wonder whether this would play nice with frameworks that manage events. I find myself working with Parsley a lot lately and it would be nice if I could combine Parsley messaging and something like AS3 signals. That would remove even more of the event handling hassle.

  3. Eric Dolecki says:

    I have a massive project I’m about to start with. I think I’ll give this a try and see how it goes. Seems very cool.

  4. Peter says:

    cool Eric, let us know how it goes — its always difficult to judge from example code if it scales well to larger real world apps.

  5. I always felt myself embarrassed working with the custom events in as3, every times looks like it’s a question of workarounds and tricky over the normal syntax.. resulting in bad code.

    I worked on a project with c++ and Qt, where slot and signal policy are the normal way to dispatch events, and this kind of “porting” (if we can call it in this way) is exactly what i’m looking for.

    Composition against Inheritance looks like an old fight, the point here is not which one is better in theory, but which is better in its implementation, and inheritance implementation of events in as3 wasn’t planned in a good way.

  6. I took a look at the code, and I like the idea but it’s probably than events since events are native in AS3.

  7. Sharedtut says:

    I don’t see anything wrong with programming and having the idea of looking ahead of the application.

    The import concept for classes is enough and simple
    to diagram your application.

    I also hear a big buzz on “Flash” dying out cuz
    too many developers can’t write and get use to as3.

    Is simple, just practice

Comments are closed.

%d bloggers like this: