Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

as3-msgpack v1.0.1

as3-msgpack is a implementation of MessagePack specification for Actionscript3 language (Flash, Flex and AIR).

Getting started:
Download the lastest release:
See online documentation:
Check the wishlist:

about message pack format

MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON but it's faster and smaller. For example, small integers (like flags or error code) are encoded into a single byte, and typical short strings only require an extra byte in addition to the strings themselves.

Check the website:

supported types

Message pack specification was built to work mostly with primitive types. You shouldn't expect a serialization library, because msgpack is similiar to JSON - but is based on binary data instead of text.
The types available are: signed/unsigned integer, single/double precision floating point, nil (null), boolean, array, associative array (map) and raw buffer.
These types are mapped to Actionscript3 as the following:

* signed integer -> int * unsigned integer -> uint * single/double precision floating point -> Number * nil -> null * boolean -> Boolean * array -> Array * associative array -> Object * raw buffer -> String or ByteArray


1.0.0 to 1.0.1

  • Using make tool to compile the binaries instead of batch files.
  • Improving
  • Creating (as3-msgpack API document for

0.4.1 to 1.0.0

  • The access interface has been totally modified. Now isn't possible to use singletons, to read/write message pack data you'll need create an object.
  • The names of classes and files were updated. The class MessagePack became MsgPack and the library MessagePack.swc became msgpack.swc.
  • Stream reading is available. If you read data from a buffer (IDataInput) and the object is not complete, the library stores the current status and then wait for more bytes.


  • bin: binaries (library and test applications);
  • lib: libraries used by test applications;
  • doc: documentation generated by asdoc;
  • src_lib: source code of the library;
  • src_test: source code of test applications (including a server and a client which exchange streaming messagepack packets through sockets);


basic usage

The usage of MsgPack class is very simple. You need create an object and call read and write methods.

```actionscript // message pack object created var msgpack:MsgPack = new MsgPack();

// encode an array var bytes:ByteArray = msgpack.write([1, 2, 3, 4, 5]);

// rewind the buffer bytes.position = 0;

// print the decoded object trace(;

### streaming
<p>You may read streaming data making successive calls to method. Each MsgPack object can handle one stream at time.<br>
If all bytes are not available, the method returns incomplete (a special object).</p>

	import org.msgpack.*;

	public class Streamer
		private var msgpack:MsgPack;
		private var socket:Socket;

		public function Streamer()
			msgpack = new MsgPack();

			// flash sockets implements the interfaces IDataInput and IDataOutput.
			// thus, these objects may be directly connected to as3-msgpack.
			socket = new Socket();
			socket.addEventListener(ProgressEvent.SOCKET_DATA, socketData);
			// connecting to our hypothetical server
			socket.connect("localhost", 5555);

		public function send(data:*):void
			// we'll write the encoded object straight into the socket (since it implements IDataOutput interface).
			msgpack.write(data, socket);

		private function socketData(e:ProgressEvent):void
			// until the data is ready, this call returns incomplete.
			var data:* =;

			// is the object complete?
			if (data != incomplete)
				trace("OBJECT READY:");

using flags

Currently there are two flags which you may use to initialize a MsgPack object:

* MsgPackFlags.READ_RAW_AS_BYTE_ARRAY: message pack raw data is read as byte array instead of string; * MsgPackFlags.ACCEPT_LITTLE_ENDIAN: MsgPack objects will work with little endian buffers (message pack specification defines big endian as default).
var msg:MsgPack;

// use logical operator OR to set the flags.
msgpack = new MsgPack(MsgPackFlags.READ_RAW_AS_BYTE_ARRAY | MsgPackFlags.ACCEPT_LITTLE_ENDIAN);


MessagePack for ActionScript3 /[ActionScript3]






No packages published