Add the messageReceived and destroyed signals to DObject rather than generating them. If they were generated, subclassing would fail on field conflicts.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6470 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.presents.dobj {
|
||||
import org.osflash.signals.Signal;
|
||||
|
||||
import flash.errors.IllegalOperationError;
|
||||
|
||||
@@ -38,6 +39,11 @@ public class DObject // extends EventDispatcher
|
||||
{
|
||||
private static const log :Log = Log.getLog(DObject);
|
||||
|
||||
public function DObject ()
|
||||
{
|
||||
new Signaller(this);
|
||||
}
|
||||
|
||||
public function getOid ():int
|
||||
{
|
||||
return _oid;
|
||||
@@ -72,6 +78,9 @@ public class DObject // extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public const messageReceived :Signal = new Signal(String, Array);
|
||||
public const destroyed :Signal = new Signal();
|
||||
|
||||
public function setDestroyOnLastSubscriberRemoved (deathWish :Boolean) :void
|
||||
{
|
||||
_deathWish = deathWish;
|
||||
@@ -414,3 +423,33 @@ public class DObject // extends EventDispatcher
|
||||
protected var _deathWish :Boolean = false;
|
||||
}
|
||||
}
|
||||
|
||||
import com.threerings.presents.dobj.MessageEvent;
|
||||
import com.threerings.presents.dobj.MessageListener;
|
||||
import com.threerings.presents.dobj.ObjectDeathListener;
|
||||
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
|
||||
class Signaller
|
||||
implements MessageListener, ObjectDeathListener
|
||||
{
|
||||
public function Signaller (obj :DObject)
|
||||
{
|
||||
_obj = obj;
|
||||
_obj.addListener(this);
|
||||
}
|
||||
|
||||
public function messageReceived (event :MessageEvent) :void
|
||||
{
|
||||
_obj.messageReceived.dispatch(event.getName(), event.getArgs());
|
||||
}
|
||||
|
||||
public function objectDestroyed (event :ObjectDestroyedEvent) :void
|
||||
{
|
||||
_obj.destroyed.dispatch();
|
||||
}
|
||||
|
||||
protected var _obj :DObject;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user