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!");
Comments