Search code examples
apache-flexheader

Error using a hyphen as an object property name in Flex


I'm trying to assemble a header object for an api request. One of the headers is 'Content-Type'. The hyphen is causing a compile error. Flex is giving me:

1050 - Cannot assign to a non-reference value.


Solution

  • You can't have a hyphen (minus sign) in your variable name. For example, if you try to have a variable a-b = 3, Flex thinks you're talking about subtraction.

    The documentation gives info about how to set headers:

    var header:URLRequestHeader = new URLRequestHeader("Content-Type", "text/plain");
    request.requestHeaders.push(header);