title: Flash: AMF3 with reference tables?
body: <p><a href="http://download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf" rel="nofollow noreferrer">AMF3 specification </a> defines use of so called "reference tables" (see Section 2.2 of this specification).</p>
  
  <p>I implemented this behavior in my AMF3 encoder/decoder I developed in Erlang, but being not very experienced with Flash API, I can hardly find how can I easily force Flash to use these reference tables when serializing objects to AMF3; for example if I use ByteArray, it seems that it just repeats full object encodings</p>
  
  <pre><code> var ba:ByteArray = new ByteArray();
   ba.writeObject("some string1");
   ba.writeObject("some string1");
   # =&gt;
   # &lt;&lt;6,25,115,111,109,101,32,115,116,114,105,110,103,49,
   #   6,25,115,111,109,101,32,115,116,114,105,110,103,49&gt;&gt;
  </code></pre>
  
  <p>(which is clearly a repetition).</p>
  
  <p>However, if these two strings are in a one single writeObject call, it does seem to use references:</p>
  
  <pre><code> ba.writeObject(["some string1", "some string1"]);
   # =&gt; &lt;&lt;9,5,1,6,25,115,111,109,101,32,115,116,114,105,110,103,49,6,0&gt;&gt;
  </code></pre>
  
  <p>Socket seems to behave the same way.</p>
  
  <p>So, can I make use of reference tables in Flash code? (provided I <strong>might</strong> have a non-standard protocol between Flash application and server )</p>
  
  <p>Thank you!</p>