Sie sind auf Seite 1von 4

Action Message Format

Action Message Format (AMF) is a binary format used jects. XML is supported as a native type. Each type is
to serialize object graphs such as ActionScript objects denoted by a single byte preceding the actual data. The
and XML, or send messages between an Adobe Flash values of that byte are as below (for AMF0):
client and a remote service, usually a Flash Media Server
or third party alternatives. The Actionscript 3 language
Number - 0x00 (Encoded as IEEE 64-bit doubleprovides classes for encoding and decoding from the
precision oating point number)
AMF format.
Boolean - 0x01 (Encoded as a single byte of value
The format is often used in conjunction with Adobes
0x00 or 0x01)
RTMP to establish connections and control commands
for the delivery of streaming media. In this case, the
String - 0x02 (16-bit integer string length with UTFAMF data is encapsulated in a chunk which has a header
8 string)
which denes things such as the message length and type
Object - 0x03 (Set of key/value pairs)
(whether it is a ping, command or media data).
Null - 0x05

ECMA Array - 0x08 (32-bit entry count)

Format analysis

Object End - 0x09 (preceded by an empty 16-bit


string length)

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 3.0, when new data
types and language features prompted an update, called
AMF3.[1]

Strict Array - 0x0a (32-bit entry count)


Date - 0x0b (Encoded as IEEE 64-bit doubleprecision oating point number with 16-bit integer
timezone oset)

Adobe Systems published the AMF binary data protocol specication[2] on December 13, 2007 and announced
that it will support the developer community to make this
protocol available for every major server platform.

1.1

Long String - 0x0c (32-bit integer string length with


UTF-8 string)
XML Document - 0x0f (32-bit integer string length
with UTF-8 string)

AMF self-contained packet

Typed Object - 0x10 (16-bit integer name length


with UTF-8 name, followed by entries)

The following amf-packet is for transmission of messages outside of dened Adobe/Macromedia containers
or transports such as Flash Video or the Real Time Messaging Protocol.

Switch to AMF3 - 0x11

AMF objects begin with a (0x03) followed by a set of


If either the header-length or message-length are un- key-value pairs and end with a (0x09) as value (preceded
known then they are set to 1 or 0xFFFFFFFF
by 0x00 0x00 as empty key entry). Keys are encoded
as strings with the (0x02) 'type-denition' byte being imuimsbf: unsigned integer, most signicant bit rst
plied (not included in the message). Values can be of any
simsbf: signed integer, most signicant bit rst
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
1.2 AMF0
bytes. This means that strings are preceded by a total of
The format species the various data types that can be three bytes which includes the 0x02 type byte. Null types
used to encode data. Adobe states that AMF is mainly only contain their type-denition (0x05). Numbers are
used to represent object graphs that include named prop- encoded as double-precision oating point and are comerties in the form of key-value pairs, where the keys are posed of eight bytes.
encoded as strings and the values can be of any data type As an example, when encoding the object below in acsuch as strings or numbers as well as arrays and other ob- tionscript 3 code.
1

var person:Object = {name:'Mike',


age:'30',
alias:'Mike'}; var stream:ByteArray = new ByteArray();
stream.objectEncoding = ObjectEncoding.AMF0;
// ByteArray defaults to AMF3
stream.writeObject(person);

SUPPORT FOR AMF

Boolean True - 0x03


Integer - 0x04 (expandable 8+ bit integer)
Double - 0x05 (Encoded as IEEE 64-bit doubleprecision oating point number)

The data held in the ByteArray is:

String - 0x06 (expandable 8+ bit integer string


length with a UTF-8 string)

Note: the object properties can be sorted in a dierent order from the one in which they are placed in actionscript.
For coloring/markup, refer to the legend below.

XML - 0x07 (expandable 8+ bit integer string length


and/or ags with a UTF-8 string)

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 ash
client):

Date - 0x08 (expandable 8+ bit integer ags with


an IEEE 64-bit double-precision oating point UTC
oset time)
Array - 0x09 (expandable 8+ bit integer entry count
and/or ags with optional expandable 8+ bit integer
name lengths with a UTF-8 names)
Object - 0x0A (expandable 8+ bit integer entry
count and/or ags with optional expandable 8+ bit
integer name lengths with a UTF-8 names)
XML End - 0x0B (expandable 8+ bit integer ags)
ByteArray - 0x0C (expandable 8+ bit integer ags
with optional 8 bit byte length)

legend: object start/end object keys object values


ecma_array
The rst 4 types are not followed by any data (Booleans
The AMF message starts with a 0x03 which denotes an have two types in AMF3).
RTMP packet with Header Type of 0, so 12 bytes are AMF3 aims for more compression and one of the ways
expected to follow. It is of Message Type 0x14, which it achieves this is by avoiding string duplication by savdenotes a command in the form of a string of value "_re- ing them into an array against which all new string are
sult and two serialized objects as arguments. The mes- checked. The byte following the string marker is no
sage can be decoded as follows:
longer denoting pure length but it is a complex byte where
(command) "_result (transaction id) 1 (value) [1] the least signicant bit indicated whether the string is 'in{ fmsVer:
FMS/3,5,5,2004 capabilities:
31.0 line' (1) i.e. not in the array or 'reference' (0) in which
mode: 1.0 }, [2] { level: status, code: NetCon- case the index of the array is saved. The table includes
nection.Connect.Success, description: Connection keys as well as values.
succeeded, data: (array) { version: 3,5,5,2004 }, In older versions of Flash player there existed one number
clientId: 1584259571.0, objectEncoding: 3.0 }
type called 'Number' which was a 64-bit double precision
encoding. In the latest releases there is an int and a uint
Here one can see an array (in turquoise) as a value of which are included in AMF3 as separate types. Number
the 'data' key which has one member. We can see the types are identical to AMF0 encoding while Integers have
objectEncoding value to be 3. This means that subsequent variable length from 1 to 4 bytes where the most signimessages are going to be sent with the 0x11 message type, cant byte of bytes 1-3 indicate that they are followed by
another byte.
which will imply an AMF3 encoding.

1.3

AMF3

2 Support for AMF

The latest version of the protocol species signicant


The various AMF Protocols are supported by many
changes that allow for a more compressed format. The
server-side languages and technologies, in the form of lidata markers are as follows:
braries and services that must be installed and integrated
by the application developer.
Undened - 0x00
Platforms:
Null - 0x01
Boolean False - 0x02

ColdFusion -[3]

3 See also

Haxe - Haxe Remoting hxformat


Java - Adobe BlazeDS, Adobe LiveCycle Data
Services (formerly known as Flex Data Services),
Exadel Flamingo, RED 5, Cinnamon, OpenAMF,
Pimento, Granite, WebORB for Java
.NET - WebORB for .NET, FluorineFx (LGPL),
DotAmf (MS-PL), AMF.NET (development
stopped)
PHP - AmfPHP, SabreAMF, WebORB for
PHP, Zend_Amf, php-amf3 extension, Baguette
AMF(php extension)
Python - PyAMF, Flashticle, amfast, Plasma
Perl
AMF::Perl,
AMF::Connection

Storable::AMF,

Curl - Curl Data Services


Ruby - RubyAMF, WebORB for Rails, Rocket
AMF
Erlang - Erlang-AMF
ActionScript - Flash Player ByteArray (in-built),
CourseVector Library
JavaScript - JSAMF
CourseVector .minerva

CourseVector

Library

Lua - lua-amf3
ABAP - ABAP AMF (early stage)
Delphi - kbmMW (extensive AMF0/AMF3 support)
iOS - CocoaAMF
Powershell - Powershell AMF
Frameworks:
Ruby on Rails - RubyAMF
Zend Framework - Zend_AMF
OSGi Framework - AMF3 for OSGi
Django - Django AMF
CakePHP - CakeAMFPHP
Grails (framework) - BlazeDS
Trac - TracRpcProtocolsPlugin. Version 1.1.0 (or
higher) of XmlRpcPlugin is required.
Web2py - PyAMF

BSON
Protocol Buers

4 References
[1] AMF 0 Specication
[2] AMF 3 Specication
[3] Features | Adobe ColdFusion 9 Standard

5 TEXT AND IMAGE SOURCES, CONTRIBUTORS, AND LICENSES

Text and image sources, contributors, and licenses

5.1

Text

Action Message Format Source: http://en.wikipedia.org/wiki/Action%20Message%20Format?oldid=654709291 Contributors: Rrjanbiah, Scragz, Hansmi, Alexf, Heirpixel, Two Bananas, Bender235, Giraedata, Toussaint, Jlward4th, FlaBot, Markhoney, JosephWatkins,
Hugo 87, Cedar101, JLaTondre, SmackBot, Nihonjoe, Andyjeries, Betacommand, Uthbrian, Miguel Andrade, Sct72, Harryboyles, Backstabb, CmdrObot, Knipping~enwiki, Alaibot, Igutekunst, Magioladitis, Alexander Abramov~enwiki, Grshiplett, Fuenfundachtzig, Areggiori, Olemis, Winterspan, WikiLaurent, RJanicek, Mild Bill Hiccup, Mydogisbox, Sun Creator, Thape, Jonverve, DumZiBoT, Jgraup,
Nathan dickamore, Addbot, Njoyce, Jncraton, MrOllie, LaaknorBot, Favonian, Ben Ben, Wonder, Lexoyo, Onthewings, Omnipaedista,
FrescoBot, LittleWink, Sam113101, Mcoderkat, MidnightCoders, , Guillaume.garcia13, Mmick66, Gilbertjgs, Roxlu, Chmarkine, Absconditus, Radistao, ForestGrass, Helmboy, Mogism, Neoxic, Arielsom, Ilankeshet, Just think72 and Anonymous: 60

5.2

Images

File:Adobe_Flash_Player_v11_icon.png Source: http://upload.wikimedia.org/wikipedia/commons/3/32/Adobe_Flash_Player_v11_


icon.png License: Public domain Contributors: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/images/shared/
product_mnemonics/128x128/flash-player-128x128.png Original artist: Adobe

5.3

Content license

Creative Commons Attribution-Share Alike 3.0

Das könnte Ihnen auch gefallen