title: Enumerate the properties of an AS3 object that may or may not be dynamic
body: <p>In order to send a POST request I need to enumerate all properties of a given object. This object may or may not be dynamic. I'm looking for the most elegant solution. This is what I've got so far:</p>
  
  <pre><code>    function createURLVariables(params:Object):URLVariables
      {
          // Workaround: Flash Player performs a GET if no params are passed
          params ||= {forcePost: true};
          var vars:URLVariables = new URLVariables();
          var propertyName:String;
          var propertyList:XMLList = describeType(params)..variable;
          var propertyListLength:int = propertyList.length();
          // A dynamic object won't return properties in this fashion
          if (propertyListLength &gt; 0)
          {
              for (var i:int; i &lt; propertyListLength; i++)
              {
                  propertyName = propertyList[i].@name;
                  vars[propertyName] = params[propertyName];
              }
          }
          else
          {
              for (propertyName in params)
                  vars[propertyName] = params[propertyName];
          }
          return vars;
      }
  </code></pre>
  
  <p>One potential problem is that this won't return properties for getters (accessors).</p>