tags:

views:

196

answers:

2

I created a custom button component that accepts an array as a property. I set the property as follows:

titleDims="[{Month: comboBox1.text, Year:comboBox2.text, Sales Order:comboBox3.text}]"

and I get the following error:

"1084: Syntax error: expecting rightparen before colon."

Wat is wrong with the array syntax?

+3  A: 

Your problem is your formatting. Let's break it down:

titleDims = [{
    Month: comboBox1.text,
    Year:comboBox2.text,
    Sales Order:comboBox3.text // Whoops! There's a space here!
}]

I suggest to change it to SalesOrder instead.

If you really need spaces in the key, you can do this:

titleDims = [{
    'Month': comboBox1.text,
    'Year': comboBox2.text,
    'Sales Order': comboBox3.text
}]
LiraNuna
+1 But interestingly, you can inject spaces in to variables names. Try this code: `var o:Object = {}; o["sales order"] = "something"; trace(o["sales order"]);` Now, as to why someone would do that, I don't know :)
Amarghosh
I tried that and I get the same error. However, I will need spaces in the keys.I even tried: titleDims="[{Month: comboBox1.text}]" and the same error is generated!
Ivan
@OP Why the quotes? That makes it a string. Isn't `titleDims=[{Month:comboBox1.text}]` what you want?
Amarghosh
just out of curiosity - `I will need spaces in the keys` - what kind of requirement is that?
Amarghosh
A: 
cb1 = comboBox1; cb2 = comboBox2; cb3 = comboBox3;

Option A

titleDims="[{'Month': cb1.text, 'Year':cb2.text, 'Sales Order':cb3.text}]";

Option B

titleDims="[{Month: cb1.text, Year:cb2.text, SalesOrder:cb3.text}]";

Option C

titleDims="[{Month: cb1.text, Year:cb2.text, Sales_Order:cb3.text}]";

I'm ignoring your use of setting titleDims to a string first and assuming you have some code that needs it that way. In the future, you don't need to quote this declaration.

dlamblin