网络上一群的废物,浪费了我几个小时,终于自己摸索到了解决方案。
1. 在flash声明一个as对象:
代码
package com.xtar.biz.constant.actionbody.chat
{
[RemoteClass(alias="com.xtar.biz.constant.actionbody.chat.WorldMessageBody")]
public class WorldMessageBody extends Object
{
public var sendername:String;
public var sendercode:String;
public var body:String;
public var createdate:Date;
public function WorldMessageBody()
{
return;
}
}
}
{
[RemoteClass(alias="com.xtar.biz.constant.actionbody.chat.WorldMessageBody")]
public class WorldMessageBody extends Object
{
public var sendername:String;
public var sendercode:String;
public var body:String;
public var createdate:Date;
public function WorldMessageBody()
{
return;
}
}
}
2. 在Java声明一个相同的对象
代码
package com.xtar.biz.constant.actionbody.chat;
import java.io.Serializable;
import java.util.Date;
public class WorldMessageBody implements Serializable
{
private static final long serialVersionUID = 5297328693553539438L;
private String sendername;
private String sendercode;
private String body;
private Date createdate;
public String getSendername()
{
return sendername;
}
public void setSendername(String sendername)
{
this.sendername = sendername;
}
public String getSendercode()
{
return sendercode;
}
public void setSendercode(String sendercode)
{
this.sendercode = sendercode;
}
public String getBody()
{
return body;
}
public void setBody(String body)
{
this.body = body;
}
public Date getCreatedate()
{
return createdate;
}
public void setCreatedate(Date createdate)
{
this.createdate = createdate;
}
}
import java.io.Serializable;
import java.util.Date;
public class WorldMessageBody implements Serializable
{
private static final long serialVersionUID = 5297328693553539438L;
private String sendername;
private String sendercode;
private String body;
private Date createdate;
public String getSendername()
{
return sendername;
}
public void setSendername(String sendername)
{
this.sendername = sendername;
}
public String getSendercode()
{
return sendercode;
}
public void setSendercode(String sendercode)
{
this.sendercode = sendercode;
}
public String getBody()
{
return body;
}
public void setBody(String body)
{
this.body = body;
}
public Date getCreatedate()
{
return createdate;
}
public void setCreatedate(Date createdate)
{
this.createdate = createdate;
}
}
3. Flash压入对象:
out.writeObject(msg.body);
4. Java使用BlazeDs接收对象:
Amf3Input : amf3in.readObject(); 这个时候,读取的object就是Java的对象。
5. Java压入对象:
Amf3Output: amf3out.writeObject(pojo); 直接压入对象。