我正在使用 Cirrus 将一些值传递给我的游戏中的其他玩家,其中一些值是对象,事情是,当我收到这些对象时,它们失去了它们的类型,它们变成了通用对象。
我读过 Cirrus 使用 AMF,但我不知道如何重新获得数据的原始对象类型。
编辑。:
//these are the 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 a parameter in the constructor or it has a string/int parameter this 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 I make EntityVO to take a non standard parameter like, a Point, like this:
EntityVO(point:Point = null)
//and I do 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(); //<- it goes into the EntityVO constructor and says that point is null, (I use point in the constructor to set something)