simulating event 'type' with signals?

5 views
Skip to first unread message

eco_bach

unread,
Nov 29, 2010, 3:13:26 PM11/29/10
to as3-signals
Hi
Can someone tell me if there is a way of simulating event type using
signals? Or do you need to create a new signal for each and every
situation where you would otherwise use a static const in a regular
custom event.

Robert Penner

unread,
Nov 29, 2010, 9:03:47 PM11/29/10
to as3-s...@googlegroups.com
You can create as many or as few signals as you need, with 0 to many
value objects dispatched.

For example, for property changes, you could make signals for each
property, e.g. fooChanged which dispatches the new value of foo.

Or, you could make one changed Signal which dispatches the name of the
changed property ("foo") along with the new value of foo:

changed.dispatch("foo", "bar");

In general, though, it's a benefit to not have to rely on string
constants for events. It may take time to get out of that mindset.

Robert

Reply all
Reply to author
Forward
0 new messages