actionscript 3 - Deserializing objects received using Cirrus -


i'm using cirrus pass values other players in game, , of values objects, thing is, when receive objects, lost type, , become generic objects.

i've read cirrus uses amf, don't know how regain original object type of data.

edit.:

//these classes involved  registerclassalias("action", action); registerclassalias("entityvo", entityvo); registerclassalias("point", point);  //action takes 3 parameters action(type:string = "", entity:entityvo = null, target:entityvo = null)  // when entityvo doesnt require parameter in constructor or has string/int parameter works:  var entity = new entityvo(); var bytearray:bytearray; bytearray = new bytearray(); bytearray.writeobject(action); bytearray.position = 0; var object:object = bytearray.readobject(); //<- works ok  //when make entityvo take non standard parameter like, point, this:  entityvo(point:point = null)  //and this:  var entity:entityvo = new entityvo(new point()); var action:action = new action("addentity", entity); var bytearray:bytearray; bytearray = new bytearray(); bytearray.writeobject(action); bytearray.position = 0; var object:object = bytearray.readobject(); //<- goes entityvo constructor , says point null, (i use point in constructor set something) 

you need 2 things:

  1. registerclassalias("alias", classoftheobjectserialized) tells flash player needs use "alias" string when reading , writing classes from/to writable/readable medium (such socket, bytearray, netconnection , on).

  2. ensure did on both ends (both sending , receiving) , objects being serialized don't have non-default arguments in constructor, properties serializable (i.e. adhere same rules described above).

ps. need aware of objects inherently not serializable, instance, none of display objects are, objects operate on resources such streams aren't serializable too. bitmapdata isn't serializable due not having default constructor.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -