0
votes

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?

2
Why do you have quotes around the array declaration?Amarghosh
I thought you had to do that when passing a parameter to an custom componentIvan
Is the custom component expecting a string or an array? isn't this json notation?Amarghosh
I could be wrong, but I think Ivan wants to set a property in MXML, so quotes are required. Ivan, in the future, please specify if you're talking about ActionScript or MXML because it's not always easy to tell from context.Josh Tynjala
Yes. Good point. I was trying to do this in MXML not Actionscript.Ivan

2 Answers

4
votes

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
}]
0
votes
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.