Communication with the background, first to understand the AMF protocol

Source: Internet
Author: User
Tags soap nets serialization web services
Flash 5 starts by transmitting data to the server in XML or "variable/value" pairing output format. While this data can be parsed automatically by the Flash compiler or manually by the developer's own code, parsing is slow. Because XML needs to process data on a per-node basis during parsing. And the data types processed using XML and the "variable/value" pairing format can only be character-type, and numbers are no exception. Instead, flash remoting can handle complex data types, such as objects, structures, arrays, and even datasets, which can be easily displayed with the DataGrid component.

In order to deal with complex data types, it is imperative to have a unique way to send data back and forth between Flash and the application server. So AMF was born. AMF is an exclusive communication protocol developed by Adobe that uses binary compression, serialization, deserialization, and data transfer to provide a lightweight, high-performance communication for flash players and flash remoting gateways.


The most important feature of AMF is that flash built-in objects, such as Object, Array, Date, XML, can be passed back to the server side, and automatically parsed into the appropriate objects on the server side, which reduces the complexity of the developer work, but also saves the development time. Because AMF uses binary encoding, this approach can compress data highly, making it ideal for transmitting large amounts of information. The larger the amount of data, the higher the performance of the Flash remoting, far more than the Web Service. As for XML, Loadvars and Loadva Ria Bles (), they use plain text transmission, and the performance is not comparable with flash remoting.

Note: Flash remoting requires a browser support bin Ary Post,flash player to run flash remoting in Nets Cape 6.x. (Flash remoting call has no effect and returns no error), Nets Cape 7 has corrected this B u g. This is also a problem for early SA Fari and Chim era versions of Macs.

The same is the lightweight data exchange protocol, also by invoking the remote service, also is the standard-based HTTP and HTTPS protocol, why Flash Remoting chose to use AMF and discard the soap and Flash player communication for the following reasons:

SOAP will process data into XML format, and the AFM is too verbose relative to the binary;
AMF can serialize data more efficiently, because AMF is intended only to support the data types of flash ActionScript, while soap is dedicated to providing a wider range of uses;
AMF Support Flash Player 6 only requires the browser to increase the size of about 4 KB (compressed), and soap is mostly;
Some of the header file requests for SOAP are not supported in Flash Player 6. So why does Flash Player 6 have access to SOAP-based Web services? The original Flash remoting gateway converts the SOAP request to the AFM format on the server side and then uses the AFM to communicate with the Flash Player. In addition, the AMF package contains Onresult events (such as the response event) and Onstatus events (such as the error event) that can be used directly in Flash.
AMF has evolved from the AMF0 of the Flash MX era to the present AMF3. AMF3 is used as the default serialization format for ActionScript 3.0 for Flash Playe 9, while AMF0 is used as the legacy version of ActionScript 1.0 and 2.0 for serialization. AMF3 is more efficient than AMF0 in transmitting data over the network. AMF3 can transfer int and UINT objects as integers (integer), and can serialize data types that are supported by ActionScript 3.0, such as Bytearray,xml and iexternalizable.

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.