AMF3 中文版介绍

所需积分/C币:3 2013-10-12 19:33:20 411KB PDF
收藏 收藏 4
举报

AMF(Act ion Message Format 动作信息格式)是用来序列化AS(ActionScript 动作脚本)实例对象的压缩的二进制格式。 这是其中文版的格式介绍。
Action Message Format-AMF3(中文版) Fixed By Chinaestone 1.3.1 Variable Length Unsigned 29-bit Integer Encoding 可变长度的无符号29位整数的编码 amF 3 makes use of a special compact format for writing integers to reduce the number of bytes required for encoding AMr3使用一种特別的压缩格式来写整数,用于压缩编码的字节数量。 As with a normal 32-bit integer, up to 4 bytes are required to hold the value however the high bit of the first 3 bytes are used as flags to determine whether the next by te is part of the integer. 对」个正常的32-bit的整数,需要4个字节来存储,然而前3个字节的最高位是用于标识下个 字节是不是整数的一部分 With up to 3 bits of the 32 bits being used as flags, only 29 significant bits remain for encod ing an integer. This means the largest unsigned integer value that can be represented is 229-l 在32-bit中多达3个bit是用来标志的,所以对编码的一个整数仅仅有29个bit有意义。这意味着最 人的无符号的整数值是22-1。 (hex) (binary) 0x00000000-0x0000007E 0x00000080-0x00003EEE: 13%%%%x% 0%x%%%xX 0x00004000-0x001EFEEF: 1%xxx%x% 1%x%%x%x 0xXXXXXx 0x00200000-0x3FFFFFFF: 1xx%%xxx 1xx%%X% 1xxXxxxx%%x% 0x40000000-OXFFFFFFEE: throw range exception In ABNF syntax, the variable leng th unsig ned 29-bit integer type is described as follows 在∧BNF语法中,可变长度的无符号的29位的整型数据类型描述如下 U29 U29-1|U29-2|U29-3|U29-4 U29-1 号x00-7E U29-2 号X80-FF旨x00-7F U29-3 号X80-EF80-FFx00-7E U29-4 号X80-FF者x80-FF80-FF号x00-FF 1.3.2 Strings and UTF-8 AMF 0 and amf 3 use(non-mod if ied)UTF-8 to encode strings. UTF-8 is the abbreviation for 8-bit Unicode Transformation Format. UTF-8 strings are typically preceded with a byte-length header followed by a sequence of variable leng th(1 to 4 octets)encoded Unicode code-points AMF0和AMF3使用UTF-8来编码字符串(没有变化的)。UTF-8是8-bit的 Unicode transformation Format(统一的传输格式)的缩写。UTF-8字符串是典型的字节长度为头,紧跟着编码 Unicode 编码点的可变长度(1到4个字节)的字节序列 aMF 3 uses a slightly modified byte-length header; a detailed descript ion is prov ided below and referred to throug hout the document AMF3使用一个轻微改变的字节长度头;适用于整个文档的具体描述如下。 (hex) (binary) 0x00000000-0x0000007F:0 XXXXXX 0x00000080-0x000007FF 110xXX103XX又XX 0200000800-0X0000EEFE:1110XX10XXX10X父x 000010000-0x0010FFEF 1110%%% 10%%xx%x 10%x*xXx 10xxxxxx In ABNF syntax, [RFC3629 describes UTF-8 as follows 在ABNF句法,[RFC3629描述UTF-8如下 what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By Chinaestone UTE8-char UTE8-1 UTE8-2 UTE8-3 UTE8-4 UTE8-1 x00-7F UTE8-2 9xC2-DF UTF8-tail UTF8-3 xE0xA0-BFU中8-tai11号xE1-EC2(UmF8-tai1) 音xED音x80-9FUTP8-ta主1|音xEE-EF2(UTF8-tai1) UTE8-4 xFO x90-BE 2(UTE8-tail) xFl-F3 3(UTF8-tail) ixF4 x80-8F 2(UTF8-tail) UTF8-tai= X80-BE For AMF 3 a string can be encoded as a string literal or a string reference 对于AMF3,一个字符串可以作为字面值或引用来编码。 a variable leng th unsigned 29-bit integer is used for the header and the first bit is flag that specifies which type of string is encoded 可变长度的无符号的29-bit的整数用于头,并且第一个bit标识字符串的编码 If the flag is 0, a string literal is encoded and the rema ining bits are used to encode the by tc-length of the utF-8 encoded String 标识为0时,字符串是字面上编码的,余下的位数是用来编码UTF-8的编码的字节的长度 If the flag is 1, then a string reference is encoded and the remaining bits are used to encode an index to the implicit string reference table 标识为1时,是字符串引用的编码,余下的位数是用来编码直指隐含的字符串引用表的一个索引。 U29s-ref U29 The first (low) bit is a flag with value 0. The remaining 1 to 28 significant bits are used to encode a string reference table index (an : integer) U29S-value U29 The first (low) bit is a flag with :value 1. The remaining 1 to 28 significant bits are used to encode the :byte-length of the UTF-8 encoded representation of the string UTE-8-empty 0x01 The UTF-8-vr empty string which is never sent by reference UTF-8-vr U29s-ref(U29s-value *(UTF8-char)) (译者注:标识位的意义前后定义的不一样) Note that this encoding imposes some theoret ical limits on the use of strings 注意:这个编码增加了字符串使用上的理论上的限制。 The number of unique Strings that can be sent by reference is limited to 228-1, and the byte-length of each UTF-8 encoded String is limited to 228-l bytes(approx 256 MB) 个被引用发送的字符串的最大长度是:238-1,每一个UTF8编码的字符串长度是22-1字节(大 概256MB)。 2 Technical SUmmary技术摘要 21 Summary ofimprovement改进的摘要 what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By Chinaestone The follow ing is a table of the improve ments and changes in aMF 3 以下是AMF3的改进和改变的目录 Object traits can now be sent by reference 对象的特性现在可以被引用发送 Strings can now be sent by reference 宇符串可以被引用发送 int/uint type support 对 int/uint类型的支持 flash utils. ByteArray type support, can also be sent by reference 对 flashutils. ByteArray类型的支持,也可以通过引用发送 flashutils. IExternalizable support 对 flashutils. EXterna lizable的支持。 Variable leng th encoding scheme for integers to reduce data size 旨在压缩数据大小的可变长度的整数的编码策略 References are sent using variable leng th integer 可变长度的整数的引用发送 String UTF-8 leng th uses variable leng th integer UTF-8的字符串长度使用可变长度的整数 Array count uses variable leng th integer 数组的长度使用可变长度的整数 A sing le Array type marker covers both strict and ECMA Arrays 个单独的Aray数组数据类型覆盖了严格的和ECM∧两个数组 Dates no longer send timezone information 日期不再发送时区信息 Dates can now be sent by reference 凵期可以通过引用发送 XMLDocument UTF-8 leng th uses variable leng th integer XMLDocument的UTF-8的长度使用可变长度整数 XMLDocu ment can now be sent by reference XMLDocu ment可以通过引用发送 XML type support, can also be sent by reference XML也可以通过应用发送 XML UTF-8 leng th uses variable leng th integer ByteArray type leng th uses variable leng th integer Boolean true and false are now sent as one by te type markers Boolean类型使用一个字节标识。 Unsupported type marker has been removed 不支持类型标志被删除了 Reserved recordset and mov ieclip type mar kers have been removed 保留了 RecordSet和 Movieclip类型标识被删除了 22 Reference Tables In AMF 3, Strings, Complex Objects(which in AMF 3 are defined as anonymous Objects, typed Objects, Arrays, Dates, XMLDocument, XML, and ByteArrays )and an Object Type's Traits can now be sent by reference 在AMF3中,字符串,复杂对象(他是AMF3中定义的匿名对象,类型化的对象,数组,日期,xml 文档,ⅹm,字节数组) what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By chinaEstone This means that instead of sending redundant information, these components of amf can simply refer to an carlier occurrence of a component 这意味着不发送冗余信息,这些AMF组件可以简单的参考先前的版本。 This reference is an integer forming a zero- based index that is encoded in the component information ypically in the first number that appears after the relevant type marker(see the type definitions for Object, Array, Date, XMLDocument, XML and Byte Array below for exact details) 这个引用从0开始索引的整数,被编码在组件信息中,典型地出现在相关的类型标识(详细情况 查阅下面 Object, array,pate, XMLDocument, XML and Byte Array类型定义)之后第一个数字。 These indexes form a virtual'table" of references that a deseria lizer and seria lizer must ma inta in when reading and writing amf 3 formatted data 这些索引形式是一个引用的虚拟表,在读写AMF3格式的数据的时候必须有一个反序列化器 和序列化其来维扩这个表 Note that 3 separate reference tables are used for Strings, Complex Objects and Object Traits respectivel. 注意:不同的引用表被用于对应的字符串,复杂对象和对象特性。 3 AMF3 Dat Types 3.1 Overview There are 13 types in AMF 3. a type marker is one by te in leng th and describes the type of encoded data that follows 有13个AMF3的类型。一个类型标识占用一个字节,描述跟着他的编码的数据类型 marker U8 The set of possible type markers are listed below (values are represented in hexadecimal format) 所有可能的类型标识罗列如下(值是用16进制表示的): undefined-marker 0x00 null-marker 0x01 false-marker 0x02 true-marker 0x03 integer-marker 0x04 double-marker =0x05 string-marker 0x06 xml-doc-marker 0x07 date-marker 0x08 array-marker 0x09 object-mark xm1-marker 0x0B byte-array-marker 0x0C Type markers may be followed by the actual encoded type data, or if the marker represents a sing le possible value(such as null) then no further information needs to be encoded 典型的标识后有真正的比啊类型数据,或者如果标识标识一个单独可能的值(如nul),就没 有编码的信息了。 what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By chinaEstone value-type undefined-marker null-marker false-marker true-marker integer-type I double-type I string-type I xml-doc-type I date-type array-type object-type xml-type byte-array-type aMF 3 makes use of three reference tables for strings, objects and traits(the characterist ics of objects that define a strong type such as the class name and public member names) AMF3使用三个引用表,分别用于字符串,对象和特性(一个强类型的对象特征有如类的名字 和公共成员名字) These tables are considered implicit as they are not encoded as a uniq ue entity in the format 这些表是隐含着的,因为他们不是作为一个在格式上唯一编码的实体。 Each ty pe that can be sent by reference may instead be encoded using an index to the appropr iate reference table 每一个可以被引用发送的实体,会使用合适的引用表屮的一个索引来编码 Strings can be sent by reference using an index to the string table 字符串能使用字符串引用表中的索引被发送。 Object, Array, XML, XMLDocu ment, Byte Array, Date and instances of user defined Classes can be sent by reference using an index to the object table 对象,数组,XML, XMLDOcu ment, ByteArray,Date和用法定义的类实例可以使用对象表 的索引来进行引用发送 Objects and instances of user defined Classes have trait information which can also be sent by reference using an index to the traits table 对象和自定义实例的特性信息也使用特性表中的索引来进行引用发送 32 undefined Type未定义类型 The undefined ty pe is represented by the undefined type marker. No further information is encoded for this value 未定义类型由未定义类犁标识来表示。对于这个值没有其他的信息。 undefihed-type unde fined-marker Note that endpoints other than the AVM may not have the concept of unde fined and may choose to represent undefined as null. 注意:不是AVM的其他终端可能没有未定义的概念,可能会选择nu*表示未定义的类型。 3.3 null Type The null type is represented by the null type marker. No further information is encoded for this value Nul型由nu类型标识来表示。对于这个值没有其他的信息 null-type null-marker 3.4 false Type The false type is represented by the false ty pe marker and is used to encode a boolean value of false False类型用iase类型标识来表示,并且用 false的 Boolean值来编码。 Note that in action Scr ipt 3.0 the concept of a primitive and object form of boolean does not exist. No further information is encoded for this value 注意:在AS3.0屮,基本的 Object形式的 Boolean概念不复存在。对于这个值没有其他的信息。 false-type false-marker what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By Chinaestone 3.5 true type The true type is represented by the true type marker and is used to encode a boolean value of true Note that in ActionScript 3.0 the concept of a primitive and object form of Boolean does not exist. No further information is encoded for this value (译者:和 false类似) true-type true-marker 3.6 integer type In aMF 3 integers are seria lized using a variable leng th unsig ned 29-bit integer. 在AMF3中,整数是使用可变长度的无符号的29bit整数来序列化。 The ActionScript 3.0 integer types-a signed int' type and an unsigned uint' type -are also represented using 29-bits in AVM+ AS3.0的整数类型,it表示有符号的,uint标识无符号的,在AVM中也使用29bit来表示 If the value of an unsig ned integer (uint)is greater or equal to 22 or if the value of a sig ned integer (int) is greater than or equal to 2 2 then it will be represented by AVm+ as a dou ble and thus seria lized in using the aMf 3 double type 如果uint整数大于或等于229int整数大于等于22,在AWM+中会用双精度浮点数来表示,并用 AMF3的双精度浮点数来序列化他。 inteaer-tvre integer-marker U29 3.7 double ty The aMF 3 dou ble ty pe is encoded in the same manner as the AMF 0 Number type AMF3的双精度浮点型和AMF0的的双精度浮点型的编码是样的。 This type is used to encode an ActionScript Number or an Action Script int of value greater than or equal to 228 or an Action Script uint of value greater than or equal to 229 The encoded value is always an 8 byte IEEE-754 dou ble precision floating point value in network byte order (sign bit in low memory) 编码的值在网络序列中总是一个8个字节的IEE-754的双精度浮点值(符号位在低位内存) bouble-type double-marker DouBle 3.8 String type Action Script String values are represented using a sing le string type in AMF 3-the concept of string and long string types from AMf 0 is not used AMF3中,AS的字符串的值用一个字符串类型来表示,AMF0中的字符串和长字符串的概念 不使用了。 Strings can be sent as a reference to a previously occurring String by using an index to the implicit string reference table Strings are encoding using UTF-8- however the header may either describe a string literal or a string relerence (详者:以上都是之前翻译了的) The empty String is never sent by reference 空的字符串不会被应用发送 string-type string-marker UTE-8-vr 3.9 XMLDocument type ActionScript 3.0 introduced a new XMl type(see 3. 13) however the legacy XMLD ocu ment type is what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By Chinaestone retained in the language as flash.xml.XMLDocument 虽然遗产类Ⅺ MLDocument被保留了下了,AS30还是引进了XML类型。 imilar to AMF O, the structure of an XMLDocument needs to be flattened into a string representation for seria lization 和AMF0类似, XMLDocument的结构需要转换为字符串表示来序列化。 As with other strings in AMf, the content is encoded in UTF-8 在AM中,因为需要字符串,其内容用UT-8来编码 XMLDocuments can be sent as a reference to a previously occurring XMLDocument instance by using an index to the implicit object reference table 对于当前产生的 XMLDocument实例,可以使用隐含的对象引用表的一个索引来进行引用发送 U29x-value U29 The first (low) bit is a flag with :value 1. The remaining 1 to 28 significant bits are used to encode the byte-length of the UTF-8 encoded representation of the XML or Ⅹ MLDocument xml-doc-type xml-doc-marker(U290-ref(U29x-value *(UTF8-char))) Note that this encoding imposes some theoret ical limits on the use of XMLD ocument. The byte-length of cach UTF-8 encoded XMLDocument instance is limited to 228-I bytes(approx 256 MB) (译者:以上都是之前翻译了的) 3.10 Date type In AMF 3 an Action Script Date is seria lize d simply as the number of milliseconds elapsed since the epoch of midnight, Ist Jan 1970 in the UTC time zone 在AMF3中,AS日期简单地序列化为一个从公元1970年1月1日零点,使用UTC时区的到现在的 亳秒数。 Local time zone information is not sent 本地时区信息不被发送。 Dates can be sent as a reference to a previously occurring Date instance by using an index to the impl icit object reference table U29D-value U29 The first (low) bit is a flag with value 1. The remaining bits are not used date-time DOUBLE :A 64-bit integer value transported as a double. date-type date-marker (0290-ref(U29D-value date-time)) 3.11 Array type ActionScript Arrays are described based on the nature of their indices, i.c. their type and how they are positioned in the array AS的数组是基于他的自然索引来描述的,例如:他们的类型和他们在数组中的位置 The follow ing table outlines the terms and their meaning what we call human nature is actually human habit Action Message Format-AMF3(中文版 Fixed By Chinaestone 术语和他的意义列出如下: strict conta ins only ordinal(numeric) indices 仅仅包含索引 ordinal ind ices start at 0 and do not contain gaps between successive ind ices(that is, every index is defined from o for the leng th of the array) 索引从0开始,不包含连续索引中的间隙(也就是说:每一个索引对于数组的长度 来说都是从0开始定义的) sparse contains at least one gap between two indices 在两个索引中至少包含一个间隙 associative conta ins at least one non-ord inal (string) index(somet imes referred to as an ECMa Array) 至少包含一个非顺序(字符串)索引(一些时候是ECMA数组) AMf considers Arrays in two parts, the dense por lion and the associa tive portion AMF把数组分为两个部分,密集部分和关联部分 The binary representation of the associative portion consis ts of name/value pairs (potentia lly none) terminated by an empty string 对于关联部分的二进制表小由以空字符串结束的名/值对(可能没有)组成 The binary representation of the dense portion is the size of the dense portion(potentially zero followed by an ordered list of values(potentia lly none) 密集部分的二进制表示是跟着顺序的列表值(可能没有)的密集部分的人小(可能是零) The order these are written in aMf is first the size of the dense portion, an empty string terminated list of name/va luc pairs, followed by size values 在AMF中写入的顺序是第一个密集部分的大小,空的字符串。 U29A-value U29 The first (low) bit is a flag with value 1. The remaining 1 to 28 significant bits are used to encode the count of the dense portion of the i Array. assOC-Va1u号 UTE-8-vr value-type array-type array-marker (0290-ref(U29A-value (UTF-8-empty I *(assoc-value)UTE-8-empty *(value-type))) 3.12 Object type A sing le aMf 3 type hand les Action Script Objects and custom user classes. The term traits'is used to describe the defining characterist ics of a class. In addition lo'anonymous'objects and typed objects ActionScript 3.0 introduces two further traits to describe how objects are serialized, namely dynamic and 'externa liza ble. The follow ing table outlines the terms and their meanings Anon ymous an instance of the actual Action Script Object type or an instance of a Class without a registered alias(that will be treated like an object on deseria lization) 真实的AS对象实例或没有别名注册的类对象实例(反序列化时,他会像对象一样 处理) what we call human nature is actually human habit

...展开详情
试读 15P AMF3 中文版介绍
立即下载 低至0.43元/次 身份认证VIP会员低至7折
    一个资源只可评论一次,评论内容不能少于5个字
    solitaryCat_deng 感谢楼主分享。
    2020-02-13
    回复
    Honyun100 很不错的资源,谢谢楼主分享。
    2018-11-01
    回复
    qqf1223 多谢,不错的东东
    2017-03-26
    回复
    zikuxuan 文件很详细,找到我想要的知识点
    2016-12-08
    回复
    gengxt2003 文件不错,有用。
    2016-06-21
    回复
    shilei1981 不错,文件挺好
    2015-07-15
    回复
    一枕清风 挺好,就是有些不详细了
    2015-06-25
    回复
    coffee777 不错,文件挺好
    2014-07-11
    回复
    img
    雷霄骅
    • 分享王者

      成功上传51个资源即可获取

    关注 私信 TA的资源

    上传资源赚积分,得勋章
    最新推荐
    AMF3 中文版介绍 3积分/C币 立即下载
    1/15
    AMF3 中文版介绍第1页
    AMF3 中文版介绍第2页
    AMF3 中文版介绍第3页
    AMF3 中文版介绍第4页
    AMF3 中文版介绍第5页

    试读已结束,剩余10页未读...

    3积分/C币 立即下载 >