DLN DLN - 4 months ago 37
Python Question

Decoding Actionscript ByteArray using python

I am using actionscript to send an array to the server with this code(I am only writing that part of the code here):-

var a:ByteArray=new ByteArray;

here I already opened a socket to a port on my server and I have a python code listenting on that port. How do I decode the bytes I receive using python when I run the swf after compiling it?
I received the following in the server side:-


ActionScript uses AMF format. There is an AMF library for Python which you can use: PyAMF.

I got this when I tested it (with Python 2.7):

>>> import pyamf
>>> for item in pyamf.decode('\n\x0b\x01\x03c\x06\x03d\x03a\x06\x03b\x01'):
...     print item
{'a': u'b', 'c': u'd'}