AS3 weirdness with URLVariables for HTTP POST

Two+ hours wasted today on dealing with this. Apparently when using URLVariables to pass variables to the server using HTTP Post, using the square bracket syntax ( vars[varname] = varvalue ) sets the contentType of the URLRequest to text/html. However setting the same variables using the dot syntax (vars.varname = varvalue) sets it to text/xml. I couldn’t set the contentType to text/xml using the [] notation no matter how I tried, whether using the URLRequest.contentType property or appending a custom “Content-Type”,”text/xml” URLRequestHeader.

Hope this helps someone.

Author: Arpit Mathur

Arpit Mathur is a Principal Engineer at Comcast Labs where he is currently working on a variety of topics including Machine Learning, Affective Computing, and Blockchain applications. Arpit has also worked extensively on Android and iOS applications, Virtual Reality apps as well as with web technologies like JavaScript, HTML and Ruby on Rails. He also spent a couple of years in the User Experience team as a Creative Technologist.

5 thoughts on “AS3 weirdness with URLVariables for HTTP POST”

  1. Interesting. If you use the constructor to initialize the URLVariables instance like so: new URLVariables(“name=John Doe”)…internally the URLVariables instance uses the bracket notation to set its dynamic properties within ‘decode’ method, but after unescaping them. Do you still see craziness going that route?

    Try calling ‘toString’ on your URLVariables instances to see what the resulting URL encoded params will look like, curious to see if there is a difference in your case between [] and ‘.’.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: