Files
narya/src/as/com/threerings/presents/dobj/EntryAddedEvent.as
T
Ray Greenwell ea0a3dce06 Well, it compiles.
It's not functional, there are still large holes in the implementation.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3868 542714f4-19e9-0310-aa3c-eee0fc999fb1
2006-02-20 03:53:04 +00:00

87 lines
2.3 KiB
ActionScript

package com.threerings.presents.dobj {
import flash.util.StringBuilder;
import flash.util.trace;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An entry added event is dispatched when an entry is added to a {@link
* DSet} attribute of a distributed entry. It can also be constructed to
* request the addition of an entry to a set and posted to the dobjmgr.
*
* @see DObjectManager#postEvent
*/
public class EntryAddedEvent extends NamedEvent
{
/**
* Constructs a new entry added event on the specified target object
* with the supplied set attribute name and entry to add.
*
* @param targetOid the object id of the object to whose set we will
* add an entry.
* @param name the name of the attribute to which to add the specified
* entry.
* @param entry the entry to add to the set attribute.
*/
public function EntryAddedEvent (
targetOid :int, name :String, entry :DSetEntry)
{
super(targetOid, name);
_entry = entry;
}
/**
* Returns the entry that has been added.
*/
public function getEntry () :DSetEntry
{
return _entry;
}
/**
* Applies this event to the object.
*/
public override function applyToObject (target :DObject) :Boolean
//throws ObjectAccessException
{
var added :Boolean = target[_name].add(_entry);
if (!added) {
trace("Duplicate entry found [event=" + this + "].");
}
return true;
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
{
if (listener is SetListener) {
listener.entryAdded(this);
}
}
// documentation inherited
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("ELADD:");
super.toStringBuf(buf);
buf.append(", entry=", _entry);
}
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeObject(_entry);
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_entry = (ins.readObject() as DSetEntry);
}
protected var _entry :DSetEntry;
}
}