Skip to content

AMF editor format

Jindra Petřík edited this page Nov 10, 2024 · 8 revisions

In FFDec you can edit data in AMF (Action Message Format) with Sol cookie editor or in PlaceObject 4 data field. There are two versions of this format, AMF0 and AMF3. FFDec uses JSON format for editing, which contains some special structures for Objects definition.

AMF0

Numbers

Same style as in ActionScript:

1, -2.5, 6e7

Boolean

Same style as in ActionScript:

true, false

String

Same style as in ActionScript:

"Hello world" with escaping using \ character like "That is \"so\" interesting".

\r for carriage return

\n for new line

\\ for backslash

\t for tab

Null

Same style as in ActionScript:

null

Undefined

ActionScript: undefined

FFDec editor:

{
  "type": "Undefined"
}

Anonymous object

ActionScript: {"a": 5, "b": true}

FFDec editor:

{
  "type": "Object",
  "members": {
    "a": 5,
    "b": true
  }
}

Ecma array type

Ecma array contains part with numeric indices starting at zero - dense part, and then associative part.

ActionScript:

var value = [57, "hello", 21.5];
value["name"] = "George";

FFDec editor:

{
  "type": "EcmaArray",
  "denseValues": {
    "0": 57,
    "1": "hello",
    "2": 21.5
  },
  "associativeValues": {
    "name": "George"
  }
}

Strict array

ActionScript: ???

FFDec editor:

{
  "type": "Array",
  "values": [63, "hi!", 13.8]
}

This type is only for completeness. ActionScript never serializes this kind of type.

Date

ActionScript: new Date(2024,12-1,3,23,16,56,5)

FFDec editor:

{
  "type": "Date",
  "value": "2024-12-03 23:16:56.005",
  "timezone": -60
}

XML Document

ActionScript: new XMLDocument("<ul><li>item</li></ul>")

FFDec editor:

{
  "type": "XMLDocument",
  "value": "<ul><li>item</li></ul>"  
}

Typed object

ActionScript3:

package {
  public class MyClass {
    public var a:int;
    public var b:String;
  }
}
//...
import flash.net.registerClassAlias;

registerClassAlias("MyClassAlias", MyClass);

var value = new MyClass();
value.a = 7;
value.b = "okay";

FFDec editor:

{
  "type": "TypedObject",
  "className": "MyClassAlias"
  "members": {
    "a": 7,
    "b": "okay"
  }
}

Reference

If any complex object is serialized twice, the second time it is written as reference. These types can use references: Object, EcmaArray, Array, Date, XMLDocument, TypedObject. In FFDec editor, the first usage of the complex object is marked with "id" field, the reference then uses the same value in "referencedId" field.

ActionScript:

var myobj = {
  "a": 5,
  "b": "hello"
};
var value = {
  "x1": myobj,
  "x2": myobj
};
{
  "type": "Object",
  "members": {
    "x1": {
      "type": "Object",
      "id": "obj1",
      "members": {
        "a": 5,
        "b": "hello"
      }
    },
    "x2": {
      "type": "Reference",
      "referencedId": "obj1"
    }
}

References can be also circular.

AMF3

Numbers

Same style as in ActionScript:

1, -2.5, 6e7

Boolean

Same style as in ActionScript:

true, false

String

Same style as in ActionScript:

"Hello world" with escaping using \ character like "That is \"so\" interesting".

\r for carriage return

\n for new line

\\ for backslash

\t for tab

Null

Same style as in ActionScript:

null

Undefined

ActionScript: undefined

FFDec editor:

{
  "type": "Undefined"
}

XML Document

ActionScript: new XMLDocument("<ul><li>item</li></ul>")

FFDec editor:

{
  "type": "XMLDocument",
  "value": "<ul><li>item</li></ul>"  
}

Date

ActionScript: new Date(2024,12-1,3,23,16,56,5)

FFDec editor:

{
  "type": "Date",
  "value": "2024-12-03 23:16:56.005"
}

Array

Array contains part with numeric indices starting at zero - dense part, and then associative part.

ActionScript:

var value:Array = ["a", "b", "c"];
value["akey"] = "hello";

FFDec editor:

{
  "type": "Array",
  "denseValues": ["a", "b", "c"],
  "associativeValues": {
    "akey" : "hello"
  }
}

Object

ActionScript 3:

package {
  public dynamic class MyClass {
    public var a:int;
    public var b:int;
  }
}

//...
import flash.net.registerClassAlias;

registerClassAlias("MyClassAlias", MyClass);

var value:MyClass = new MyClass();
value.a = 7;
value.b = 29;

value["c"] = "hello";

FFDec editor:

{
 "type": "Object",
 "className": "MyClassAlias",
 "dynamic": true,
 "sealedMembers": {
    "a": 7,
    "b": 29
  },
  "dynamicMembers": {
    "c": "hello"
  }
}

Without registering the alias using registerClassAlias, the "className" field will have value of empty string.

XML

ActionScript 3:

var value:XML = <ul><li>item</li></ul>;

FFDec editor:

{
  "type": "XML",
  "value": "<ul><li>item</li></ul>"  
}

ByteArray

ActionScript 3:

import flash.utils.ByteArray;
var value:ByteArray = new ByteArray();
value.writeByte(0x12);
value.writeByte(0x34);
value.writeByte(0xAB);

FFDec editor:

{
  "type": "ByteArray",
  "value": "1234ab"
}

The data are written in "value" field in hexadecimal form.

Vector

ActionScript 3:

var value:Vector.<int> = new Vector.<int>();
value.push(10);
value.push(20);
value.push(30);

FFDec editor:

{
  "type": "Vector",
  "fixed": false,
  "subtype": "int",
  "values": [10, 20, 30]
}

Dictionary

ActionScript 3:

import flash.utils.Dictionary;

var value:Dictionary = new Dictionary(false);
var key1:Object = { myid: 1 };
var key2:Object = { myid: 2 };

value[key1] = "First";
value[key2] = "Second";

FFDec editor:

{
  "type": "Dictionary",
  "weakKeys": false,
  "entries": [
    {
      "key": {
        "type": "Object",
        "className": "",
        "dynamic": true,
        "sealedMembers": {
        },
        "dynamicMembers": {
          "myid": 1
        }
      },
      "value": "First"
    },
    {
      "key": {
        "type": "Object",
        "className": "",
        "dynamic": true,
        "sealedMembers": {
        },
        "dynamicMembers": {
          "myid": 2
        }
      },
      "value": "Second"
    }
  ]
}

Reference

If any object is serialized twice, the second time it is written as reference. These types can use references: XMLDocument, Date, Array, Object, XML, ByteArray, Vector, Dictionary. In FFDec editor, the first usage of the complex object is marked with "id" field, the reference then uses the same value in "referencedId" field.

ActionScript:

var myobj = {
  "a": 5,
  "b": "hello"
};
var value = {
  "x1": myobj,
  "x2": myobj
};
{
  "type": "Object",
  "members": {
    "x1": {
      "type": "Object",
      "id": "obj1",
      "members": {
        "a": 5,
        "b": "hello"
      }
    },
    "x2": {
      "type": "Reference",
      "referencedId": "obj1"
    }
}

References can be also circular.