Introduction to AS3Signals
Peter Elst - Flex@Beach ’10
Who am I?
Freelance Flash Platform consultant
Founding Partner of Project Cocoon Multimedia
Author to “Object-Oriented ActionScript 3.0”
What is AS3Signals?
Open source project by Rob Penner
Alternative way to working with events in AS3
Inspired by C# events and Signals/Slots in QT
Lightweight, easy and fast to use
Lets get back to basics
What is wrong with this?
Requires inheritance to dispatch events
Need to subclass Event to pass around data
String references as events rather than objects
Misses basic functionality (remove all listeners etc.)
What does AS3Signals do?
Uses composition over inheritance
Doesn’t require subclassing to pass arguments
Listeners subscribe to Objects not a String reference
Can hook up to native Events
Most lightweight Signal class
Passes any number of arguments
Supports optional strong typing for arguments
Does everything Signals does
Adds support for target and signal that dispatched it
Passes GenericEvent to listener
Uses Signal to wrap around native Events
Requires object, event type and event class arguments
Uses IEventDispatcher to dispatch
Similar to the NativeSignal class
Has its own dispatch code rather than IEventDispatcher
Integration with frameworks
removeAll - removes all listeners to a signal
addOnce - ﬁres a signal event only the ﬁrst time
numListeners - returns how many listeners for a signal
There is experimental event bubbling support
How well does it perform?
zero listeners one listener
Where can you get it?
Feel free to get in touch!