Get Control of Your AS3 Event Flow With Signals
Tutorial Details
- Difficulty: Intermediate
- Platform: Flash (Flash Player 9+)
- Language: AS3
- Software Used: FlashDevelop (optional)
- Estimated Completion Time: 30 minutes
In this screencast we’ll go over all you need to know about AS3 Signals — a light-weight strongly-typed alternative to the native Flash event system. Prepare to see events in a whole new way!
Signals is a library by Robert Penner that allows for easy AS3 messaging between objects and classes. It lets you wire your applications with better APIs and less boilerplate code than regular AS3 Events.
In this video, I’ll introduce Signals, with a simple demo application that shows how it can be used.
Watch the Screencast
Links
- Signals on github: https://github.com/robertpenner/as3-signals
- Robert Penner on Twitter: http://twitter.com/robpenner
- Guide to FlashDevelop: http://active.tutsplus.com/tutorials/beginners-guide-to-flashdevelop-intro-basix/
Signals Cheat Sheet
// Create a Signal without specific Value Classes
var signal:Signal = new Signal();
// Add listeners
signal.add(myListener);
signal.add(myOtherListener);
// Dispatch signal
signal.dispatch();
// Add one-time listeners that gets removed after first call
signal.addOnce(willOnlyBeCalledOnceListener);
// Remove listener
signal.remove(myListener);
// Dispatch signal with values
signal.dispatch("my string", "my other string", instanceOfObject);
// Create a Signal WITH specific Value Classes
var signalWithValueClasses:Signal = new Signal(String, int);
// Any dispatch on this Signal requires at least a String and an int but can accept more than that, like so:
signalWithValueClasses.dispatch("hello", 25, "I'm optional, but allowed!");

Hey everyone!
I’ll be watching the comments here closely for at least a few days (and now and then from that point on) in case anyone has any questions/suggestions regarding this.
I am not sure I understand why I would use this over regular flash events. Would you be able to explain how you would you this in a real life example? It seems like a great tool but feels redundant.
Thks for the tutorial, I recently had a problem passing params to the callback function of a listener, but this is a great solution to that.
I think that maybe is redundant too but it feel like a little more freedom because you write your own callback function as well.
Thanks again!!
PD: Somebody knows where I can find good resources about designing an object oriented software, I mean I need to understand how I get started making a good object-oriented software with AS3.
AS3-Signals is great.
Here is a slideshow, GIT Code Sample, and screencast video about the fantastic AS3-Signals.
http://www.rivellomultimediaconsulting.com/as3-signals-introduction/