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
- Signals on github: https://github.com/robertpenner/as3-signals
- Robert Penner on Twitter: http://twitter.com/robpenner
- Guide to FlashDevelop: https://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!");
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post