Action Message Format
   HOME

TheInfoList



OR:

Action Message Format (AMF) is a binary format used to serialize object graphs such as ActionScript objects and XML, or send messages between an Adobe Flash client and a remote service, usually a Flash Media Server or third party alternatives. The Actionscript 3 language provides classes for encoding and decoding from the AMF format. The format is often used in conjunction with Adobe's RTMP to establish connections and control commands for the delivery of streaming media. In this case, the AMF data is encapsulated in a ''chunk'' which has a header which defines things such as the message length and type (whether it is a "ping", "command" or media data).


Format analysis

AMF was introduced with Flash Player 6, and this version is referred to as AMF0. It was unchanged until the release of Flash Player 9 and
ActionScript ActionScript is an object-oriented programming language originally developed by Macromedia Inc. (later acquired by Adobe). It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript (mean ...
3.0, when new data types and language features prompted an update, called AMF3. Flash Player 10 added vector and dictionary data types documented in a revised specification of January 2013.
Adobe Systems Adobe Inc. ( ), formerly Adobe Systems Incorporated, is an American software, computer software company based in San Jose, California. It offers a wide range of programs from web design tools, photo manipulation and vector creation, through to ...
published the AMF binary data protocol specification in December 2007 and announced that it will support the developer community to make this protocol available for every major server platform.


AMF self-contained packet

The following ''amf-packet'' is for transmission of messages outside of defined Adobe/Macromedia containers or transports such as Flash Video or the
Real Time Messaging Protocol Real-Time Messaging Protocol (RTMP) is a communication protocol for streaming media, streaming audio, video, and data over the Internet. Originally developed as a proprietary protocol by Macromedia for streaming between Flash Player and the Flash ...
. If either the header-length or message-length are unknown then they are set to -1 or 0xFFFFFFFF uimsbf: unsigned integer, most significant bit first simsbf: signed integer, most significant bit first


AMF0

The format specifies the various data types that can be used to encode data. Adobe states that AMF is mainly used to represent object graphs that include named properties in the form of key-value pairs, where the keys are encoded as strings and the values can be of any data type such as strings or numbers as well as arrays and other objects. XML is supported as a native type. Each type is denoted by a single byte preceding the actual data. The values of that byte are as below (for AMF0): * Number - 0x00 (Encoded as IEEE 64-bit double-precision floating point number) * Boolean - 0x01 (Encoded as a single byte of value 0x00 or 0x01) * String - 0x02 (16-bit integer string length with UTF-8 string) * Object - 0x03 (Set of key/value pairs) * Null - 0x05 * ECMA Array - 0x08 (32-bit entry count) * Object End - 0x09 (preceded by an empty 16-bit string length) * Strict Array - 0x0a (32-bit entry count) * Date - 0x0b (Encoded as IEEE 64-bit double-precision floating point number with 16-bit integer time zone offset) * Long String - 0x0c (32-bit integer string length with UTF-8 string) * XML Document - 0x0f (32-bit integer string length with UTF-8 string) * Typed Object - 0x10 (16-bit integer name length with UTF-8 name, followed by entries) * Switch to AMF3 - 0x11 AMF objects begin with a (0x03) followed by a set of key-value pairs and end with a (0x09) as value (preceded by 0x00 0x00 as empty key entry). Keys are encoded as strings with the (0x02) 'type-definition' byte being implied (not included in the message). Values can be of any type including other objects and whole object graphs can be serialized in this way. Both object keys and strings are preceded by two bytes denoting their length in number of bytes. This means that strings are preceded by a total of three bytes which includes the 0x02 type byte. Null types only contain their type-definition (0x05). Numbers are encoded as double-precision floating point and are composed of eight bytes. As an example, when encoding the object below in actionscript 3 code. var person:Object = ; var stream:ByteArray = new ByteArray(); stream.objectEncoding = ObjectEncoding.AMF0; // ByteArray defaults to AMF3 stream.writeObject(person); The data held in the ByteArray is: Note: the object properties can be sorted in a different order from the one in which they are placed in actionscript. For coloring/markup, refer to the legend below. The code above will work only for built-in classes like Object. To serialise and deserialise custom classes, the user needs to declare them using the registerClassAlias command or else an error will be thrown by the player. // for a hypothetical class Person registerClassAlias("personTypeAlias", Person); Although, strictly speaking, AMF is only a data encoding format, it is usually found encapsulated in a RTMP message or Flex RPC call. An example of the former can be found below (it is the "_result" message returned in response to the "connect" command sent from the flash client): legend: object start/end object keys object values ecma_array The AMF message starts with a 0x03 which denotes an RTMP packet with Header Type of 0, so 12 bytes are expected to follow. It is of Message Type 0x14, which denotes a command in the form of a string of value "_result" and two serialized objects as arguments. The message can be decoded as follows: (command) "_result" (transaction id) 1 (value) , Here one can see an array (in turquoise) as a value of the 'data' key which has one member. We can see the objectEncoding value to be 3. This means that subsequent messages are going to be sent with the 0x11 message type, which will imply an AMF3 encoding.


AMF3

The latest version of the protocol specifies significant changes that allow for a more compressed format. The data markers are as follows: *Undefined - 0x00 *Null - 0x01 *Boolean False - 0x02 *Boolean True - 0x03 *Integer - 0x04 (expandable 8+ bit integer) *Double - 0x05 (Encoded as IEEE 64-bit double-precision floating point number) *String - 0x06 (expandable 8+ bit integer string length with a UTF-8 string) *XMLDocument - 0x07 (expandable 8+ bit integer string length and/or flags with a UTF-8 string) *Date - 0x08 (expandable 8+ bit integer flags with an IEEE 64-bit double-precision floating point UTC offset time) *Array - 0x09 (expandable 8+ bit integer entry count and/or flags with optional expandable 8+ bit integer name lengths with a UTF-8 names) *Object - 0x0A (expandable 8+ bit integer entry count and/or flags with optional expandable 8+ bit integer name lengths with a UTF-8 names) *XML - 0x0B (expandable 8+ bit integer flags) *ByteArray - 0x0C (expandable 8+ bit integer flags with optional 8 bit byte length) The first 4 types are not followed by any data (Booleans have two types in AMF3). Additional markers used by Flash Player 10 (the format is still referred to as AMF3) are as follows: *VectorInt - 0x0D *VectorUInt - 0x0E *VectorDouble - 0x0F *VectorObject - 0x10 *Dictionary - 0x11 AMF3 aims for more compression and one of the ways it achieves this is by avoiding string duplication by saving them into an array against which all new string are checked. The byte following the string marker is no longer denoting pure length but it is a complex byte where the least significant bit indicated whether the string is 'inline' (1) i.e. not in the array or 'reference' (0) in which case the index of the array is saved. The table includes keys as well as values. In older versions of Flash Player there existed one number type called 'Number' which was a 64-bit double precision encoding. In the latest releases there is an int and a uint which are included in AMF3 as separate types. Number types are identical to AMF0 encoding while Integers have variable length from 1 to 4 bytes where the most significant bit of bytes 1-3 indicates that they are followed by another byte.


Support for AMF

The various AMF Protocols are supported by many server-side languages and technologies, in the form of libraries and services that must be installed and integrated by the application developer. Platforms: * ColdFusion -Features Adobe ColdFusion 9 Standard
/ref> *
Haxe Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software, released under an MIT License. ...

Haxe Remotinghxformat
*
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...

Adobe BlazeDSAdobe LiveCycle Data Services (formerly known as Flex Data Services)Exadel FlamingoRED 5

CinnamonOpenAMFPimentoGraniteWebORB for Java
*
.NET The .NET platform (pronounced as "''dot net"'') is a free and open-source, managed code, managed computer software framework for Microsoft Windows, Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft emplo ...

WebORB for .NETFluorineFx
(LGPL)
DotAmf
(MS-PL)
AMF.NET
(development stopped) * PHP - AmfPHP
SabreAMFWebORB for PHPphp-amf3 extensionBaguette AMF(php extension)
* Python -
amfast
*
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...

AMF::PerlStorable::AMFAMF::Connection
*
Curl cURL (pronounced like "curl", ) is a free and open source computer program for transferring data to and from Internet servers. It can download a URL from a web server over HTTP, and supports a variety of other network protocols, URI scheme ...

Curl Data Services
*
Ruby Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...

RubyAMFWebORB for RailsRocket AMF
* Erlang
Erlang-AMF
*
ActionScript ActionScript is an object-oriented programming language originally developed by Macromedia Inc. (later acquired by Adobe). It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript (mean ...

Flash Player ByteArray
(in-built)
CourseVector Library
*
JavaScript JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior. Web browsers have ...

JSAMFCourseVector LibraryCourseVector .minerva
* Lua
lua-amf3
*
ABAP ABAP (Advanced Business Application Programming, originally ''Allgemeiner Berichts-Aufbereitungs-Prozessor'', German for "general report preparation processor") is a high-level programming language created by the German software company SAP SE. ...

ABAP AMF (early stage)
*
Delphi Delphi (; ), in legend previously called Pytho (Πυθώ), was an ancient sacred precinct and the seat of Pythia, the major oracle who was consulted about important decisions throughout the ancient Classical antiquity, classical world. The A ...

kbmMW (extensive AMF0/AMF3 support)
*
iOS Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...

CocoaAMF
*
PowerShell PowerShell is a shell program developed by Microsoft for task automation and configuration management. As is typical for a shell, it provides a command-line interpreter for interactive use and a script interpreter for automation via a langu ...

Powershell AMF
Frameworks:
Apache Royale communication with AMF and RemoteObject

Apache Royale
*
Ruby on Rails Ruby on Rails (simplified as Rails) is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web pa ...

RubyAMF
*
Zend Framework Laminas Project (formerly Zend Framework or ZF) is an open source, object-oriented web application framework implemented in PHP 7 and licensed under the New BSD License. The framework is basically a collection of professional PHP-based pac ...

Zend_AMF
* OSGi Framework
AMF3 for OSGi
* Django
Django AMF
*
CakePHP CakePHP is an open-source web framework. It follows the model–view–controller (MVC) approach and is written in PHP, modeled after the concepts of Ruby on Rails, and distributed under the MIT License. CakePHP uses well-known software engin ...

CakeAMFPHP
*
Grails (framework) Grails is an Open-source software, open source web application framework that uses the Apache Groovy programming language (which is in turn based on the Java (Sun)#Platform, Java platform). It is intended to be a high-productivity framework by fo ...

BlazeDS
*
Trac Trac is an open-source, web-based project management and bug tracking system. It has been adopted by a variety of organizations for use as a bug tracking system for both free and open-source software and proprietary projects and products. Tr ...

TracRpcProtocolsPlugin
Version 1.1.0 (or higher) o
XmlRpcPlugin
is required. * Web2py
PyAMF


See also

*
BSON BSON (; Binary JSON) is a computer data interchange format extending JSON. It is a binary form for representing simple or complex data structures including associative arrays (also known as name-value pairs), integer indexed arrays, and a suit ...
*
Protocol Buffers Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs that communicate with each other over a network or for storing data. The method involves an ...
*
Local shared object A local shared object (LSO), commonly called a Flash cookie (due to its similarity with an HTTP cookie), is a piece of data that websites that use Adobe Flash may store on a user's computer. Local shared objects have been used by all versions o ...


References

{{Data Exchange Adobe Flash Data serialization formats