开发者

Flex: Unexpected leakage with RemoteObject + IExternalizable?

I've been tinkering with IExternalizable, but I've noticed some unexpected behavior. I've got this class:

public function readExternal(input:IDataInput):void {
    input.readObject();
    input.readObject();
    input.readObject();
}

public function writeExternal(output:IDataOutput):void {
    output.writeObject("first string");
    output.writeObject(424242);
    output.wr开发者_如何学运维iteObject("second string");
}

But when I try to serialize this class using AMF and send it to a remote server (via RemoteObject), Charles shows me that the request looks like this:

unexpected result http://img.skitch.com/20100406-cjawastycagp1x2chbe76k2suu.png

But it seems wrong that my serialized object is leaking out into the rest of the request.

So, what am I doing wrong? Is there some part of the documentation I've missed?


You code seems fine, however you should serialize using the proper methods (writeUTF for strings, writeInt for int etc). Anyway Charles seems to not work properly with objects implementing IExternalizable (I'm using version 3.4.1), so you should not rely on what it is showing.

Not directly related to your question - do you really need to use IExternalizable? You are going to lose some benefits related to AMF compression algorithm (unless you are not going to implement all this things in your writeExternal method).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜