     public var sRef :References = new References();
     public var tRef :References = new References();
 
-    public function EncodingContext (bytes :ByteArray)
+    public function Context (bytes :ByteArray)
     {
         this.bytes = bytes;
     }

{
    public static function encode (bytes :ByteArray, value :*) :void
    {
        encodeValue(new Context(bytes), value);
    }

    private static function encodeValue (context :Context, value :*) :void
    {
        if (value === undefined) {
            context.bytes.writeByte(0x00);

        } else if (value === null) {
            context.bytes.writeByte(0x01);

        } else if (value === false) {
            context.bytes.writeByte(0x02);

        } else if (value === true) {
            context.bytes.writeByte(0x03);            

        } else if (value is int || value is uint || value is Number) {
            // figure out if this number could be represented as an AMF3 int
            if (value is int) {
                // signed integers must lie within -2^28 and 2^28-1
                doublify = (value < -(1 << 28)) || (value >= (1 << 28));

            encodeString("");
        }

        _ctx.oRef.table[object] = _ctx.oRef.ix ++;
    }


    private static function encodeByteArray (bytes :ByteArray) :void
    {
        if (_ctx.oRef.table[bytes] !== undefined) {
            encodeInteger(_ctx.oRef.table[bytes] << 1);
            return;
        }

        // a byte array consists of a 1 bit, followed by the byte count
        encodeInteger(1 | (bytes.length << 1));
        // and then just... all the bytes
        _ctx.bytes.writeBytes(bytes);

        _ctx.oRef.table[bytes] = _ctx.oRef.ix ++;
    }

    private static var _ctx :Context;
}
}

import flash.utils.ByteArray;
import flash.utils.Dictionary;

class Context
{
