/* Authors: Wishnu Prasetya, Alexander Elyasov, Arie Middelkoop Copyright 2011 Utrecht University The use of this sofware is free under the Modified BSD License. */ package eu.fittest.Logging.Serialization { import eu.fittest.Logging.ISerialization.*; import eu.fittest.actionscript.automation.*; import flash.events.*; import flash.utils.*; /** * Contians a bunch of function-delegates for the serialization of events. */ public class EventSerializableDelegates { /** * To serialize a flash-event. */ public static function serializationDelegate(e : Event, s : Serializer) : void { s.beginObject(e,Object(getQualifiedClassName(e))) ; s.storeField(Object("type"), e.type) ; s.storeField(Object("target"), e.target) ; s.endObject() ; } /** * To serialize a record-event. This event is produced by our mixin, and wraps * around an ordinary flash-event. When the latter occurs, the mixin will * produces the corresponding record-event. This will be the event that we will * catch for logging. From it we can still infer the original event, but additionally * the mixin can have the ability to infer a unique ID for the target of the event. */ public static function recordEventserializationDelegate(e : RecordEvent, s : Serializer) : void { s.beginObject(e,Object(getQualifiedClassName(e))) ; s.storeField(Object("targetID"), e.source.id) ; s.storeField(Object("type"), e.cmd.action) ; s.storeField(Object("args"), e.cmd.args) ; s.endObject() ; } } }