From d652de50e74f3212b1e14da9362385447984e517 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 28 Feb 2007 02:58:45 +0000 Subject: [PATCH] I should have created this a while back. Sometimes we just want to wild-up some custom event to communicate a value to listeners. This is for that. CommandEvents are close, but are all dispatched using a single 'type' value, so a single handler must have a switch statement in it (unless you're a controller, which has magic to call the right method.) git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4606 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/ValueEvent.as | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/as/com/threerings/util/ValueEvent.as diff --git a/src/as/com/threerings/util/ValueEvent.as b/src/as/com/threerings/util/ValueEvent.as new file mode 100644 index 000000000..d8598a7b3 --- /dev/null +++ b/src/as/com/threerings/util/ValueEvent.as @@ -0,0 +1,35 @@ +package com.threerings.util { + +import flash.events.Event; + +/** + * A handy event for simply dispatching a value associated with the event type. + */ +public class ValueEvent extends Event +{ + /** + * Accessor: get the value. + */ + public function get value () :Object + { + return _value; + } + + /** + * Construct the value event. + */ + public function ValueEvent (type :String, value :Object) + { + super(type); + _value = value; + } + + override public function clone () :Event + { + return new ValueEvent(type, _value); + } + + /** The value. */ + protected var _value :Object; +} +}