Skip to main content
Inspiring
March 5, 2009
Question

Transcoding AMF

  • March 5, 2009
  • 2 replies
  • 656 views
It is my desire to transmit some data encoded in Action Message Format (AMF3) over a socket to and from Flash. I need to know two things:

1) How to read AMF3 data off a Flash Socket object. I'm assuming it will come through as an array of bytes and that array of bytes must be decoded into actual Actionscript Strings/Arrays/Objects or whatever.

2) How to turn Actionscript vars into AMF encoded binary strings.

Surely there is some built-in flash object which can do this? AMFPHP encodes data into AMF for transmission and its Actionscript client code looks like the attached example.

That code appears to be AS2 and relies on the remoting and rpc classes

The other example is from Zend_Amf (a framework) that also uses AMF and they offer some AS3 code that uses NetConnection and Responder objects.

It would appear that these built-in flash primitives are built for Remote Procedure Calls and expect return values to be communicated. I don't see any actual transcoding of objects from/into AMF which is what I really want. Any help would be much appreciated.

This topic has been closed for replies.

2 replies

sneakyimpAuthor
Inspiring
March 6, 2009
thanks so much!
Inspiring
March 6, 2009
Responses to amf calls get decoded into native objects automatically. AMFPHP has as3/amf3 suport as well in recent versions.

But you can also do your own encoding in actionscript.

Check out the ByteArray class.
You can set the amf encoding version and use writeObject() to encode.
Encoding is either amf0 (as1 and as2) or amf3 (as3) version