Final scheme of using AMF object transmission in Java and flash

Source: Internet
Author: User

It took me a few hours to waste a group of waste resources on the Internet and finally found a solution.

 

1. Declare An as object in flash:

Code 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 ;
}
}
}

 

 

2. declare the same object in Java

Code Package Com. xtar. biz. Constant. actionbody. Chat;

ImportJava. Io. serializable;
ImportJava. 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;

PublicString getsendername ()
{
ReturnSendername;
}

Public VoidSetsendername (string sendername)
{
This. Sendername=Sendername;
}

PublicString getsendercode ()
{
ReturnSendercode;
}

Public VoidSetsendercode (string sendercode)
{
This. Sendercode=Sendercode;
}

PublicString getbody ()
{
ReturnBody;
}

Public VoidSetbody (string body)
{
This. Body=Body;
}

PublicDate getcreatedate ()
{
ReturnCreatedate;
}

Public VoidSetcreatedate (date createdate)
{
This. Createdate=Createdate;
}

}

 

 

3. Flash push objects:

Out. writeobject (msg. Body );

 

4. Java uses blazeds to receive objects:

Amf3input:Amf3in. readobject (); at this time, the read object is a Java object.

 

5. Java push objects:

Amf3output: amf3out. writeobject (pojo); press the object directly.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.